Tuesday 31 March 2015

Call External Web Service using Custom Action in CRM 2013/15


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.

Scenario

Agents need to capture the temperature of City on Case form based on City selected on City Field. 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
Note: In order to achieve this directly with JavaScript, performing Step 2 of the action would require to make a cross-domain call from JavaScript.

Process Configuration

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:


  1. Read the city and country inputs
  2. Initialize the web service client object and make the web service call
  3. Set the values back in the output fields to be available in the process















Calling Action from JavaScript



This is the last piece of the puzzle. At this point, we simply need to call the action created from a JavaScript event (ribbon button clicked, on change of a value etc.). In order to achieve this, create a function that is called when the client even occurs. That function should execute the Action, read the output values and set the field values on the form. This has to be done with a SOAP call. There are two ways to do this. 

You can:

Use below link to call Custom Action using Javscript-


Hope this help.

2 comments:

  1. Great articles, first of all Thanks for writing such lovely Post! Earlier I thought that posts are the only most important thing on any blog.
    CRM Software In India
    CRM Software In Chennai
    CRM Software

    ReplyDelete
  2. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to

    (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time.

    Contact him now and thank me later.

    ReplyDelete

Blogger Widgets