We had a requirement to convert a won Opportunity to a Contract. Since this is not an out-of-the-box feature, what we did to achieve this is we’ve created a custom action.

Calling a Custom Action Using JavaScript

There are two things needed for us to complete this task: JavaScript and a plugin. But for the first part of my blog, we’ll discuss the execution of the custom action using JavaScript.

First thing to do is create a custom action. I named it Convert to Contract.

create process


Next, we’ll define the parameters. Since we need to have the record values of the opportunity to convert to a contract, add the Opportunity entity as an Input in the Process Arguments.

define the parameters


I didn’t add any steps since we’ll use a plugin to do the conversion of opportunity to contract, which I’ll discuss in the second part of this blog.

Save the new custom action then activate.

Next part is calling the action using JavaScript. You can use the Process.js from codeplex.com. It simplifies the calling of workflows, dialogs as well as actions. But for this blog, I used the Web API to execute an action. Here’s the script I used:

Calling a Custom Action Using JavaScript 2


I created the following variables to indicate the details of the actions including the name, action parameters and link. Then I called the action using the WEB API library with the variables as my parameters.

Once the action is complete, it will call on the success callback that would display a notification in the header bar.

Now create a ribbon in the opportunity form and use the ConvertToContract function.

Try to execute the Convert to Contract button and see if it works.


Actions are ways to add custom messages in an entity. Before I use JavaScript alone to execute custom processes or features which can later have some limitations. But since we have the custom actions, we can combine JavaScript and plugins. And we could have several messages that we could use to complete some customization requirements.