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

  • Community Member Profile Picture
    on at
    RE: Dynamics API setActiveProcess fails on Opportunity records

    RajarajanS - I have answered your questions.

  • Community Member Profile Picture
    on at
    RE: Dynamics API setActiveProcess fails on Opportunity records

    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.

  • Verified answer
    RajarajanS Profile Picture
    on at
    RE: Dynamics API setActiveProcess fails on Opportunity records

    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>

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,145 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,917 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans