Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Lead to Opportunity BPF stage is not moving

(0) ShareShare
ReportReport
Posted on by

Hi,

I have a requirement where I have to update the Business Process Flow real-time on changing field status selected by the user. 

The same requirement I have achieved on Opportunity entity BPF (custom BPF) and working fine. but I am getting an issue when the BPF stage moves from Lead to Opportunity after Lead qualification.

46152344.Capture.PNG

Error Status 500:

Javascript

if (optionText == "Bid Process") {   //Checking option in which BPF stage will move
if (getActiveProcess.toUpperCase() == "919E14D1-6489-4852-ABD0-A63A6ECAAC5D") //checking Lead to Opportunity BPF
{
var Stage2 = "3A275C22-FC45-4E89-97FC-41E5EC578743"; // Stage ID 
var entity = {};
entity["activestageid@odata.bind"] = "/processstages(" + Stage2 + ")";  
entity["traversedpath"] = stageId + ", " + Stage2;    // StageId is the active stage ID calling dynamically
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/leadtoopportunitysalesprocesses(" + currentBPFInstanceID + ") ", true);   // here currentBPFInstanceID is process InstanceId and calling dynamically.
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success – No Return Data – Do Something
//alert("Success");
} else {
alert("Error");
//Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}

  • Community Member Profile Picture
    on at
    RE: Lead to Opportunity BPF stage is not moving

    I have a concern that when Lead Qualified to Opportunity than the same Business Process flow work (leadtoopportunitysalesprocess) in Opportunity entity. When I have created background workflow on Lead to Opportunity BPF but the same workflow is not getting trigger. The same process is working fine when I create opportunity directly (without qualifying the lead)

  • Community Member Profile Picture
    on at
    RE: Lead to Opportunity BPF stage is not moving

    Thanks Bipin for reply, As suggested by you I have update the code with Xrm.WebApi but the same error I found.

    Please check the below error Respose.

    pastedimage1597299918336v1.png

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Lead to Opportunity BPF stage is not moving

    Hi,

    Only Http status 500 will not help to find out the issue.

    Could you please click on request which you highlighted in screenshot from network tab and check response details which will have detailed error details.

    Is there any reason why you are using xrmhttprequest instead of using xrm.webapi?

    var entity = {};
    entity["activestageid@odata.bind"] = "/processstages(1123)";
    entity.traversedpath = "ttt";
    
    Xrm.WebApi.online.updateRecord("leadtoopportunitysalesprocess", "00000000-0000-0000-0000-000000000000", entity).then(
        function success(result) {
            var updatedEntityId = result.id;
        },
        function(error) {
            Xrm.Utility.alertDialog(error.message);
        }
    );

    Please Mark My Answer Verified If I Were Helpful

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 102

Overall leaderboard

Product updates

Dynamics 365 release plans