Version 9.0 – Execute custom action with all parameter types in Dynamics CRM Version 9.0

Execute custom action with all parameter types in Dynamics CRM Version 9.0

Dynamics Version 9.0 introduced the Xrm.WebApi namespace which provides all the methods to interact with dynamics CRM server from client side script.

Detailed Documentation – https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi

However recently I was working on a project to upgrade the SOAP calls from client and replace them with the new Xrm.WebApi methods. Create/ delete/ update were kind of easy and was easily ported to the new API’s.

However then came the Actions. The client had actions which had many input parameters and which were getting invoked from the client using SOAP calls. We had to port them to the Xrm.WebApi. But in Xrm.WebApi we did not had any function like executeAction. But the Xrm.WebApi.execute came to our rescue.

Let’s first examine Xrm.WebApi.execute method. Microsoft documentation shows it like this –

Xrm.WebApi.execute(request).then(successCallback, errorCallback);

For the sake of brevity of this blog post, I am skipping the documentation of the parameters. For detailed information on the parameters, please refer the below Microsoft documentation link – https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/execute

So how to call an action with input parameters? For this post, I created an action named “new_TestAction”. The action is global. It has the following input parameters.

  • Name – Type (string)
  • Age – Type(string)
  • InputEntityReference – Type (EntityReference)
  • InputEntity – Type (Entity)
  • InputEntityCollection – Type(EntityCollection)

For entityreference, entitycollection and entity, I have kept the Entity as Account Entity. All set and done. Now the next step is to call the action. below is the sample code to create the request object. All the important parameters has been highlighted and appropriate comments put.

TestAction1: function (input1, input2, inputEntityReference, inputAccount, inputAccountCollection) ,
“Input2”: ,
“InputEntityReference”: ,
“InputEntity”: ,
“InputEntityCollection”:
},
operationType: 0, // 0 for action, 1 for function and 2 for CRUD
operationName: “new_TestAction1”
};
};
}

Next is the code to create this request object and pass the object to the action.

ExecuteAction: function () ;
var accountEntity = ;
var accountEntityCollection =[
,
];
var requestObject = new TestAction1(“Name”, “Age”, accountReference, accountEntity, accountEntityCollection);
Xrm.WebApi.execute(requestObject).then(function (result) ,
function (error) );
}

Simple isn’t it. I haven’t covered the other primitive types like – Decimal/ Int. They are pretty simple like for int, it is Edm.Int32.

Hope this helps!

 

{Zero Code development} Putting images in Dynamics 365 view for encoding Case severity

Putting images in Dynamics 365 view for encoding Case severity

Another fantastic article for Deepesh Somani

MSDYNAMICSBLOG BY DEEPESH

Business Requirement: Often there is requirement to show Case severity in some colour encoded way in Dynamics 365. For example, refer image below:

clip_image002

Solution: Below steps can be used to achieve this requirement without writing code:

1. Go to Settings->Customization->Entity->fields and add a new field of type Option Set. In the example above I have created a new field Case Severity on Case entity. Add items text from the following link: http://classic.getemoji.com/

Following images were used in the above example:

clip_image004

clip_image006

2. Add the column as the first field in Active Case view and other views that you wish. Optionally, you can also place the field on the Case entity form. Next, in the editable grid you will be able to set the priority by this field:

clip_image008

3. Not only that, you will be able to group as well by selecting Group by:

clip_image010

 

What Microsoft Dynamics 365 Can Do for Your Business

 

If you haven’t yet tried Microsoft Dynamics 365, you’ve come to the right place. Let’s go over the basics. This cloud-based platform builds and expands upon the features of Microsoft Dynamics CRM 2016 while allowing you to access and upload data anytime, anywhere. It focuses on and unites the things that matter most to your business: people, data, and processes.

Big or small, non- or for-profit, Microsoft Dynamics 365 offers something for every organization Subscriptions are flexible and allow you to purchase the specific apps and access levels that make the most sense for you. If you don’t need the functionality of an app, you don’t have to pay for it. If 90 percent of team members don’t need administrative privileges, the price reflects it, with user licenses available for as little as $8 per month.

Combining customer relationship management (CRM) and enterprise resource planning (ERP) tools, Microsoft Dynamics 365 provides everything from customer-facing portals and  automated email marketing campaigns targeted at specific markets to coordinating across departments and scheduling the appropriate resources based on skill, location, and availability.

Dynamics 365 can aid your customer engagement, employee empowerment, operations optimization, and product transformation efforts, and take your business to the next level.

Check out xRM.com to download a free 30-day trial of Microsoft Dynamics 365, access hundreds of free instructional videos, and learn about our training and implementation packages. \

 

Visit page

What Microsoft Dynamics 365 Can Do for Your Business