In this article, I am providing an example of how actions can be used to make a request to a web service outside of the CRM domain from a record’s form event.
When users call an incident management center, the agents need to capture the temperature at the time of the incident in the city where it occurred. In order to do so, we decide to create a button on the command bar that agents can click on and that will perform the following tasks:
- Read the City and Country information from the form
Call an Action that
- Takes the City and Country as parameters
- Use an external web service to get the temperature in the city
- Returns the temperature as output parameters
- Sets the temperature field value on the form
To start things off, let’s start be creating an Action of type process. This action will have 2 input values (City and Country) and 2 output values (Temperature in Fahrenheit and in Celsius).
The steps are really simple. The action needs to a custom workflow activity that will connect to a weather web service and return the temperature in two output values of its own.
Custom Workflow Activity
Here you can see what the custom workflow activity code looks like. It’s very straight forward in that it only has 3 steps:
- Read the city and country inputs
- Initialize the web service client object and make the web service call
- Set the values back in the output fields to be available in the process
- use Deepak’s example as show in his blog post here or
This is another great example of how actions can be leveraged to work around challenges that we’ve dealt with in the pre-CRM 2013 era. Keep in mind that in order to call an external web service from the custom workflow activity, there are server security elements to take into consideration (e.g. can my server talk to the web service? etc.)
Hope this helps!