This project has moved. For the latest updates, please go here.

Using custom action

Dec 2, 2015 at 4:26 AM
Hi

I am trying to use the custom action 'dxtools_SendCustomEmail' through my code but I am getting object reference not set to an instance..... error. Below is my code

OrganizationRequest request = new OrganizationRequest("dxtools_SendCustomEmail");
request.Parameters.Add("EmailTemplateName", templateName);
request.Parameters.Add("ToRecipient", to);
request.Parameters.Add("FromSender", new EntityReference("systemuser", whoAmI.UserId));
request.Parameters.Add("Regarding", payment.ToEntityReference());
request.Parameters.Add("RecordContext", payment.ToEntityReference());

OrganizationResponse reponse = _helper.OrgService.Execute(request);

When I open the custom action and view the properties for first step 'Create email' nothing is mapped to the input parameters. Do I need to do something to make this work?

Thanks
Coordinator
Dec 7, 2015 at 6:43 PM
Hi Mirhassanali,

Do you get more details from the tracing?

Have a look at this integration test, it may help you as an example:
https://crmcustomemails.codeplex.com/SourceControl/latest#Src/Dev/DXTools.CRM.Solutions.CustomEmails/DXTools.CRM.Solutions.CustomEmails.IntegrationTests/Actions/SendCustomEmailTest_WithStaticParameters.cs

The custom action provides 2 options to supply parameters: input parameters and workflow context parameters. Have a look at this code:

https://crmcustomemails.codeplex.com/SourceControl/latest#Src/Dev/DXTools.CRM.Solutions.CustomEmails/DXTools.CRM.Solutions.CustomEmails.Workflows/CreateCustomEmailActivity.cs

Ramon
Dec 9, 2015 at 3:08 AM
Hi

Got it working after adding the following parameter:

request.Parameters.Add("Attachments", string.Empty);

Thanks