Write Automated Code

It doesn’t matter what tool you use for testing your software, the question to you one day will always be the same.

“Can we automate it?”

Can we take you out of the mix and run it on it’s own?

Can we run it across different tenants concurrently with it “crossing the streams”?

Can we send it a 1000x simultaneous requests to see how it does?

Think about the code you’ve written over the last few months – would any of it satisfy these three tests for code that can be automated?

It’s not easy and generally involves an extra amount of testing and development in understanding these scenarios and applying them to your current project set.

But that’s where you shine right?

That’s where you take the tasks that people grind on, you fix them, you automate them, you save time and money and you get back to doing the work that matters right?

Despite all that hubris it is not always that easy and often times it is much harder to convince your Project Lead why you need to understake these tasks for something that might not be requested for another 6 or 12 months.

And this is true.

And the counter to this argument is that if you build it today, that means you can start automating those tests today, you can start updating multiple environments and topologies today, you can start testing against a higher degree of performance thresholds that you are receiving today.

And that’s where the value and the need for this comes from. Because in the moment where you are going to really, really need this type of architecture and design to be in place in your code, you are not going to have the time to wait 2 – 3 weeks for it to be ready.

You don’t have to tackle it all in one fell swoop.

Start small, pick a component that could value most from these capabilities that you are currently work on and build in that functionality. Then over time, keep building in a little more here and a little more there.

And when the day comes that you get asked those three questions, your answer will be –  “Yes, simply turn it on here and you are good to go”.

And that is the answer that every worried Customer Support Technician wants, Stressed Out QA Tester and hopeful Sales Engineer wants to hear to know that your code is ready for the big leagues.

Now let’s go and do it.

Creating a Custom Interactive button in Dynamics

It’s been awhile since I played with the Ribbon Workbench and I had to re-familiarize myself with it to deploy some custom button functionality to a Dynamics tenant.

If you’re not familiar with the Ribbon Workbench, go download it and bask in it’s glory and time saving capabilities.

Once you install the solution into your Dynamics system, usage is as simple as selecting the solution you want your new button to be deployed to, dragging a button onto the Form toolbar and creating a command object that calls a function in your specified JavaScript file.

Creating the Button

As you can see from the screenshot, my function is called SendMail and called from a library within the provided file.  When I first started coding this button, I added a simple alert() to the initial function call so I could quickly validate the buttons functionality, deploy it and move on to the rest of the implementation.


There are a host of other options in creating a button related to display rules and Hide actions which can make your implementation that much more dynamic.

What I really like about the Ribbon Workbench is that the customizations are deployed directly to your solution without having to deploy the workbench solution between environments.

No external Dependencies = awesome development!

User Interaction

In my scenario, the button that I created was calling an action where the results were passed back to my calling function – for better or for worse.

Adding to my integration, I sent a notification back to the client when the action had completed.  If there was an error, the error was sent to the client.

For an Informative warning this looked like.

Xrm.Page.ui.setFormNotification("Authorization successfully sent.", "INFORMATION");

And in the case of an error.

 function (e) {
 // Error
 console.log("Workflow Err: " + e);
Xrm.Page.ui.setFormNotification("Could not Authorize, Error: " + e, "ERROR");

When both solutions are thrown together, a great integration story for facilitating calls to a custom service, action or workflow and updating users on the status of those calls when completed.