web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Opportunity Sales Process Isn't Auto-Connected to an Opportunity

(1) ShareShare
ReportReport
Posted on by 16
Hello,
 
I have an issue with Opportunity Sales Process.
 
When I start with a Lead and qualify that Lead, an Opportunity is created and the Sales Process is auto-connected to that Opportunity.
However, when I create a Lead from a Contact so that some existing fields can be populated into the Lead form, the Sales process isnt connected. Therefore, the users have to select the process for that Opportunity. We only have 1 process so my client doesnt want to select the process everytime they create an opportunity.
 
Is there a way to fix this? Can I use Power Automate to connect a process to an Opportunity?
 
I have the same question (0)
  • Suggested answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    You can implement this with the following JavaScript code.
     
    var Sdk = window.Sdk || {};
    (function () {
        //A global variable to store information about enabled business processes after they are retrieved asynchronously
        this.enabledProcesses = [];
       
        // Code to run in the OnLoad event
        this.formOnLoad = function (executionContext) {
            // Retrieve the formContext
            var formContext = executionContext.getFormContext();
     
            //Determines if there is currently an active Bussines process flow.
            if(formContext.data.process.getActiveProcess()){
                return;
            }
     
            // Retrieve Enabled processes
            formContext.data.process.getEnabledProcesses(function (processes) {
                //Move processes to the global Sdk.enabledProcesses array;
                for (var processId in processes) {
                    Sdk.enabledProcesses.push({ id: processId, name: processes[processId] })
                }
                console.log("Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.");
               
                //Write the values of the Sdk.enabledProcesses array to the console
                if (Sdk.enabledProcesses.length < 0) {
                    console.log("There are no enabled business process flows for this table.");
                }
                else {
                    console.log("These are the enabled business process flows for this table:");
     
                    //Determines if the current entity has only one enabled Bussines process flow.
                    if(Sdk.enabledProcesses.length === 1){
     
                      //Sets the BPF in the current entity as the active BPF.
     
                        var enabledProcessId = Sdk.enabledProcesses[0].id;
                        formContext.data.process.setActiveProcess(enabledProcessId)
                       
                    }              
                }
            });
        };
      }).call(Sdk);
     
    The APIs used are referenced below.
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     
  • HC-16032012-0 Profile Picture
    16 on at
    Hi Dengliang Li,

    I appreciate your help.
    I've implemented the code, but it still not working.


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 202 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 70

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans