web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Changing Business Process Flow Stage by C#

(0) ShareShare
ReportReport
Posted on by 35

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:

6433.Screenshot_5F00_1.jpg

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.

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    I think there are 2 possible issues:

    1. I'd check the value for your activeStageId is correct, just to be sure
    2. It may be due to the overall flow, as your stages look to go from Lead to Opportunity to Quote and then to Opportunity again, and the problem may be with going back to the Opportunity - this is based on the 'New Stage Entity: bpf_opportunityid not found' error. Is it necessary to go back to the Opporunity in the BPF, or could you do this in another way (e.g. run a workflow)
  • Danstec Profile Picture
    35 on at

    Thank you for the reply, David.

    1. I'm sure, that I use the correct id value for activestageid field. I took it from fetchXML request.

    2. Maybe I don't understand your thought. The opportunity has already existed when BPF was in the 3-rd stage, and when I click on "Next Stage" button, it just goes to this opportunity for future closing. What do you mean by another way?

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans