Hello Everyone,
I am using a Console App to replace Business Process Flow from old Lead Records which are using the old Business Process Flow. I have written a Console App which works perfectly fine to update the records with new BPF. However, I run into an issue when I open any old existing lead record with the old BPF, then try running my Console App, and it still doesn't update the record with new BPF, only because i opened the record once. It successfully updates the record with new BPF if I don't open the record.
I am not sure what am i missing and where the error could be.
Below is the code i am using in my console app:
QueryExpression qe = new QueryExpression { EntityName = "lead", ColumnSet = new ColumnSet(true) };
qe.Criteria.AddCondition("firstname", ConditionOperator.Equal, "Hulk");
qe.Criteria.AddCondition("lastname", ConditionOperator.Equal, "Hogan");
//qe.Criteria.AddCondition("statecode", ConditionOperator.Equal,0);
//QueryExpression qe = new QueryExpression("lead");
EntityCollection ec = serviceClient.RetrieveMultiple(qe);
Console.WriteLine("Retrieved {0} records", ec.Entities.Count);
try
{
ec.Entities.ToList().ForEach(x =>
{
SetProcessRequest request = new SetProcessRequest();
request.Target = new EntityReference("lead", x.Id);
request.NewProcess = new EntityReference("workflow", new Guid("********-****-****-****-************"));
serviceClient.Execute(request);
});
}
catch (Exception e)
{
Console.WriteLine(e);
}
Appreciate your help with this.
Thank you,