OK... and by code, how this can be done?
I have this part
#region Properties
[Output("Get email"), ReferenceTarget("email")]
public OutArgument<EntityReference> Email { get; set; }
private ITracingService m_tracingService;
#endregion
private void Trace(string message)
{
if (this.m_tracingService != null)
{
this.m_tracingService.Trace(message);
}
}
public void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
{
if (crmWorkflowContext == null)
{
throw new ArgumentNullException("crmWorkflowContext");
}
try
{
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory factory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
m_tracingService = executionContext.GetExtension<ITracingService>();
EntityReference emailTosend = new EntityReference();
Run(service, Registration.Get(executionContext), out emailTosend);
Email.Set(executionContext, emailTosend);
}
catch (FaultException<OrganizationServiceFault> e)
{
// Handle the exception.
throw e;
}
}
public void Run(IOrganizationService service, EntityReference registerReference, out EntityReference emailToSend)
{
//the rest goes here
}