Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

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

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?
 
  • 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
     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans