How to call Entity specific Action using c#

 We can call Entity specific action in any place

Ex. This we can execute using Js or we can call this using a console application or we can call this action using plug in. Here it will take input arguments(if you specify in your action) and returns output variable.


Action will not execute in below conditions

  • When the action is in Draft state
  • When the action is profiled

Hence, once you move or import the solution to the higher instance make sure all the Process will be in Active state.

Enough of explanation....


Now Below piece of code to call entity specific action.

for establishing the connection in console you can refer this URL

The difference between Entity specific action and global action is, for entity specific action we should add Target attribute where global action it's not required. If you are not specify the Target attribute for entity specific action it will give error(Error: Target attribute is required)

In below example we have used 2 input varibales.

  • AccountName (type:String)
  • ContactReference(type:EntityReference)

 OrganizationRequest req = new OrganizationRequest("YOUR ACTION NAME");

            EntityReference accountReference = new EntityReference("account", new Guid("ee8ac79f-29a3-eb11-b1ac-00224804e422"));

            req.Parameters.Add(new KeyValuePair<string, object>("Target", accountReference));

            req.Parameters.Add(new KeyValuePair<string, object>("AccountName", "TestSample account from console"));

            req.Parameters.Add(new KeyValuePair<string, object>("ContactReference", new EntityReference("contact", new Guid("26061f64-99ba-4121-ba3e-e5021411c783"))));

            OrganizationResponse Response = organizationService.Execute(req);


if you specify any output variable then it will be captured in Response object.

 


Comments

Popular posts from this blog

Connecting Dynamics 365 Web api using external HTML page

Get azure blob files inside Sub Directories

Interview questions on MS CRM