I need to retrieved all emails value from fetchxml query in workflow activity.
I need to retrieved all emails value from fetchxml query in workflow activity.
I will quote myself:
You would not be able to do that. What you can do is to pass pre-created email as a parameter to that custom workflow activity and populate "to" field of it based on your query. I did something similar in my workflow toolkit. As an example you can check this - github.com/.../SendEmailToTeam.cs
The problem that i need to retrieve multi contacts as one output of type EntityReference
here is code which return one contact as per highlighted ,so is it possible to return multi contacts once and use this output to send one mail to multi contacts as per attached screenshot.
public class GetAllContacts : CodeActivity
{
[RequiredArgument]
[Input("FetchXML Query")]
public InArgument<string> FetchXmlQuery { get; set; }
[Input("FetchXML Query Format Argument 1")]
public InArgument<string> FetchXmlQueryFormatArg1 { get; set; }
[Output("Contacts List")]
[ReferenceTarget("contact")]
public OutArgument<EntityReference> EntityRef { get; set; }
protected override void Execute(CodeActivityContext context)
{
var entityReference = new EntityReference();
var serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
var service = serviceFactory.CreateOrganizationService(Guid.Empty);
var recordsToProcess = service.RetrieveMultiple(new FetchExpression(GetFormattedFetchQuery(context)));
if (recordsToProcess != null && recordsToProcess.Entities != null && recordsToProcess.Entities.Count()>0)
{
entityReference = recordsToProcess.Entities.FirstOrDefault().ToEntityReference();
EntityRef.Set(context, entityReference);
}
}
private string GetFormattedFetchQuery(CodeActivityContext context)
{
var query = this.FetchXmlQuery.Get(context);
return String.Format(query,
this.FetchXmlQueryFormatArg1.Get(context));
}
}
}
Please, don't create follow up of previous thread as a new one. Can you please be more specific - what exactly doesn't work?
I created new Workflow activity with Fetchxml as an input and the output is a list of recipient emails in one variable as output but when i trying to set this output in TO field of step send mail not accepted as this field it a lookup for (contacts or Account.etc) , so how can i map the out put to this field (to)
Hello,
You would not be able to do that. What you can do is to pass pre-created email as a parameter to that custom workflow activity and populate "to" field of it based on your query. I did something similar in my workflow toolkit. As an example you can check this - github.com/.../SendEmailToTeam.cs
Feel free to update the thread if you have any questions.
I read it but i still don't know how to return multiple email addresses in one output (from fetchxml query ) in workflow activity to send one mail for many recipients
Hi,
See below link to construct fetchxml and use in workflow activity.
docs.microsoft.com/.../use-fetchxml-construct-query
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156