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.
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));
}
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)
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.
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); } );
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Muhammad Shahzad Sh...
106
Most Valuable Professional
Eugen Podkorytov
102