Skip to main content
Dynamics 365 Community / Forums / Sales forum / Opportunity Sales Proc...
Sales forum
Suggested answer

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

editSubscribe (0) ShareShare
ReportReport
Posted on by 9
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?
 
Attachments
  • Opportunity Sales Process Isn't Auto-Connected to an Opportunity
    Hi Dengliang Li,

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


  • Suggested answer
    Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    Opportunity Sales Process Isn't Auto-Connected to an Opportunity
    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
     

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
a33ik Profile Picture

a33ik 84,305 Super User

#2
Sukrut Parab Profile Picture

Sukrut Parab 71,633

#3
YUN ZHU Profile Picture

YUN ZHU 60,219 Super User

Featured topics

Product updates

Dynamics 365 release plans