Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Changing Business Process Flow Stage by C#

$
0
0

Hi!

I have the BPF for my selling process, that works for a lead, quote, and opportunity.

I need to change the stage from quote to closing opportunity programmatically by C# but catch the exception "System.ServiceModel.FaultException" with the message:

"Invalid stage transition. Transition to stage <stage id> is not in the process active path. TraversedPath: <first stage id>,<second stage id>,<third stage id>, StageId: <current third stage id>, ProcessId: <new fourth stage id>. New Stage Entity: bpf_opportunityid not found."

The process, I need to change is in the screenshot:

There is my code from custom activity Execute method:

//New stage id
var activeStageId = new Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");

// Retrieve the process instance record to update its active stage
ColumnSet bPFcolumnSet = new ColumnSet();
bPFcolumnSet.AddColumn("activestageid");
Entity retrievedProcessInstance = _client.Retrieve("new_sales_process_flow", new Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"), bPFcolumnSet);
                
// Update the active stage to the next stage
retrievedProcessInstance["activestageid"] = new EntityReference("processstage", activeStageId);
_client.Update(retrievedProcessInstance);


What I'm doing wrong?

Thanks for the help.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>