- Navigate to Settings->Process->New.
- Use following details and click on OK :
- Process name: ActionDemo
- Category: Action
- Entity: None(global)
- Type: New blank process
- Add a Input parameter of Entity type for ParentAccount record like below:
- Add another input parameter of type EntityReference to get Salesperson
Now let’s say we want to use these parameters to create our contact record, so follow below steps to create contact record using these parameters:
- Click on Add Step and select Create Record step under drop down
- Select Contact under Create drop down like below and click on Set Properties.
- Now we will be using our Entity object input parameter to fetching different property and will be setting in contact record
- Select the field that you want to set, for example we want to set Account Name, so click on Account Name field and click on OK after setting following options from Form Assistant like below:
- Similar we can select other fields like Email, Mobile, Firstname, Last name from account entity object like below
- Now select the Sales person field and select out second parameter from Form assistant like below (Note: We have created a custom lookup for Sales Person field in Contact entity) and click on Save and Close
Now we need to activate our action and we can call it using server side code, client side code and using other Workflow and dialogs as well (new feature in CRM 2015). We ca use following code call our action:
//we have written method to get CRM service object
IOrganizationService service = connection.GetCRMService();
//retrieve account record using that we want to create contact
Entity accountObj = service.Retrieve(“account”, new Guid(“699D9F32-9B10-E511-80FD-C4346BAD3138″), new ColumnSet(true));
//Create organization Request object and pass action name as parameter
OrganizationRequest Req = new OrganizationRequest(“new_actiondemo”);
Req[“ParentAccount”] = accountObj; //passing our first parameter
Req[“Salesperson”] = new EntityReference(“systemuser”, new Guid(“90322292-C8EC-4A72-8B32-B79DEF7DD31C”));
//use execute method to call action
OrganizationResponse Respons = service.Execute(Req);
After execution of the code we can see in CRM contact record is created by action like below:
So in above example we show if we need to pass multiple parameter we can use Entity object instead of passing field value one by one and entity reference is used to for passing a single entity reference instance.