locked
CRM 2011 - OutArgument<Contact> ERROR RRS feed

  • Question

  • I am trying to create a Custom Workflow that retrieves contacts related to an incident and email them all on one email (using email template). Because I could not add the N:N contact records using the workflow designer, I decided to write a custom workflow to create an List<ActivityParty> and add the local variable to the "CC" field on an email process. However, after writing the workflow activity, I could not register the assembly. I was given the Error Message, "The type OutArgument`1 of the property emailaddress is not supported."

    Could somebody explain the OutArgument<t> types accepted, or explain a better approach to attach multiple N:N contact records to a email "CC" field from a workflow. 

    [Output("EmailAddress")]
    public OutArgument<ActivityParty> emailaddress { get; set; }
    protected override void Execute(CodeActivityContext context)
    {
    var wfContext = context.GetExtension<IWorkflowContext>();
    var serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService organizationService = serviceFactory.CreateOrganizationService(wfContext.InitiatingUserId);
    emailaddress.Set(context, EmailAddressBuilder(ref organizationService, wfContext.PrimaryEntityId));
    }

     
    Friday, May 16, 2014 4:00 PM

Answers

  • So to answer my own question. I was not able to return an Entity back, so I switched to a different approach. Instead, I wrote a custom workflow that would actually send the email (from template) after gathering all recipients. I used the following

       var emailUsingTemplateReq = new SendEmailFromTemplateRequest
                            {
                                Target = email.ToEntity<Entity>(),
                                TemplateId = template.Id,
                                RegardingId = regardingId,
                                RegardingType = Incident.EntityLogicalName
                            };
                            var emailUsingTemplateResp = (SendEmailFromTemplateResponse)crmService.Execute(emailUsingTemplateReq);

    • Marked as answer by Shaun Laurio Tuesday, May 20, 2014 4:44 PM
    Tuesday, May 20, 2014 4:43 PM