Home > CRM 2013 > Execute Custom Action using Late Binding – CRM 2013

Execute Custom Action using Late Binding – CRM 2013

Custom Actions provide the ability to write reusable modules of logic that can be triggered through client-side or server-side code.

Custom actions run synchronously and can take in parameters as well as return values.

In this article I will walk you through creation of a Custom Action with Input Parameters and execute the same using SDK call.

My Custom Action created on ‘Account’ entity and will do below actions

  • Takes a Input Parameter of type ‘Entity Reference’ to User, to set Owner of the Task to Accounts Owner
  • Create a new Task
Custom Action

Custom Action

  • Sets Owner of Task to Account’s Owner
Custom Action - Create Task

Custom Action – Create Task

  • Make sure you publish the ‘Custom Action’

Execute Custom Action :

  • We can execute Custom Action using Early or Late binding approach
  • For early binding we need to generate wrapper using exe tool by including ‘generateActions’ tag in console command.

CrmSvcUtil.exe /url:http://<serverName>/<organizationName>/XRMServices/2011/Organization.svc /out:<outputFilename>.cs /username:<username> /password:<password> /domain:<domainName> /namespace:<outputNamespace> /serviceContextName:<serviceContextName> /generateActions

  • Below is the code to execute using Late Bound technique

OrganizationRequest executeCreateTaskOnAccount = new OrganizationRequest(“new_CreateTaskOnAccount”);
// Set Account Owner EntityReference Input Parameter
Guid accountOwnerId={Account Owner GUID};
var accountOwner = new EntityReference(“systemuser”, accountOwnerId);
executeCreateTaskOnAccount.Parameters.Add(new KeyValuePair<string, object>(“AccountOwner”, accountOwner));

Few points :

  • Custom actions can be triggered using JScript and SDK calls
  • We cannot execute Custom Actions from a workflow
  • However you can create a Custom Workflow with ‘Custom Action’ execution logic and call from a Workflow
  • A security privilege named Activate Real-time Processes (prvActivateSynchronousWorkflow) is required to activate an action’s real-time workflow so that it can be executed


Categories: CRM 2013 Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: