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 365 | Integration, Dataverse...
Answered

Dynamics API setActiveProcess fails on Opportunity records

(0) ShareShare
ReportReport
Posted on by

I'm attempting to automatically set the process of an Opportunity record to the 'Lead to Opportunity Sales Process'. So far I have tried both Power Automate / Flow and programmatically with Javascript via a web resource on the Form Properties.

Setting Using Javascript

This method works flawlessly on a Lead record, but on an Opportunity I receive the error 'POST /api/data/v9.0/SetProcess 500' 

function setBPF(executionContext) {
  var formContext = executionContext.getFormContext();
  console.log("Checking business process flow.");
  if (formContext.data.process.getActiveProcess()) {
    console.log("Business process flow found.");
    var activeProcessID = formContext.data.process.getActiveProcess().getId();
    if (activeProcessID.toUpperCase() != "919E14D1-6489-4852-ABD0-A63A6ECAAC5D") {
      formContext.data.process.setActiveProcess("919E14D1-6489-4852-ABD0-A63A6ECAAC5D", callBackFunction);
    } else {
      console.log("Business process flow is already set.");
    }
  } else {
      console.log("Business process flow is NULL.");
      formContext.data.process.setActiveProcess("919E14D1-6489-4852-ABD0-A63A6ECAAC5D", callBackFunction);
    }
};



function callBackFunction(result) {
  if (result == "success") {
    console.log("Business process flow updated.");
  } else {
  console.log("Business process flow was not updated.");
  }
};

Setting Using Power Automate / Flow

This method seems to set the Process ID value fine, but when the record is loaded the Lead to Opportunity Sales Process UI is not visible at the top of the record. Further, the above Javascript reports that the activeProcess is still null when applied.

When a new record is created in Dynamics with a type of Lead > Update record 'Process ID' to '919E14D1-6489-4852-ABD0-A63A6ECAAC5D'

I would prefer the first solution, but we often mass-qualify our Leads and so the record is never opened (and thus the Process isn't set). Because of this I would like to use the same logic on an Opportunity, but receive a 500 error:

POST /api/data/v9.0/SetProcess 500

I have the same question (0)
  • Verified answer
    RajarajanS Profile Picture
    on at

    Hello Partner, 

    Is this JS failing on opportunity records? If so, are you trying to update the BPF to the opportunity records that are created newly or existing ones.

    As of yet, SetActiveProcess Client API is not supported on Create Forms but it should ideally work fine on update forms. 

    Refer to article: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-data-process/activeprocess/setactiveprocess general usage of this API>

  • Community Member Profile Picture
    on at

    Yes, as the title states it does not work on Opportunity records, only Leads. And I am attempting to use it specifically on existing records. The documentation has been no help, the code should work on all existing records regardless of entity type, from what I understand.

  • Community Member Profile Picture
    on at

    RajarajanS - I have answered your questions.

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 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans