I would like to update the opportunity pipeline stage when creating the first quote record. Is there a way to do this using javascript?
I would like to update the opportunity pipeline stage when creating the first quote record. Is there a way to do this using javascript?
Hi,
Glat that it worked. Please mark my answer verified if my asnwer were helpful.
Thank you so much, it worked!
Hi,
Try below javascript code to set active stage pipeline.
formContext.data.process.setActiveStage(stageId, callbackFunction);
Parameter
stageId String Yes The ID of the completed stage for the entity to make the active stage.
callbackFunction Function No A function to call when the operation is complete. This callback function is passed one of the following string values to indicate whether the operation succeeded:
- success: The operation succeeded.
- invalid: The processId isn’t valid or the process isn’t enabled.
You can also use web api to update bpf stage if form context is different.
var entity = {}; entity["activestageid@odata.bind"] = "/processstages(00000000-0000-0000-00000001)"; entity["opportunityid@odata.bind"] = "/opportunities(00000000-0000-0000-00000001)"; var req = new XMLHttpRequest(); req.open("PATCH", Xrm.Page.context.getClientUrl() "/api/data/v9.1/leadtoopportunitysalesprocesses(00000000-0000-0000-0000-000000000000)", true); 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.onreadystatechange = function() { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { //Success - No Return Data - Do Something } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(entity));
Because I would like to update the step only after creating the first record and I'm not familiar with using workflow.
Hello,
There is a way but why do you want to do it using JavaScript - more cleaner and no-code way - to use Workflow or Flow.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156