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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Populate default business process flow onload form

(1) ShareShare
ReportReport
Posted on by
Hello,
 
in Sales Hub app, Lead entity with a main form: SalesHub-Lead. There are two Lead BPFs in this app: SalesHub- Lead to Opportunity Process (Custom) and Lead to Opportunity Process (System).
 
Requirement: Opening SalesHub-Lead form always display the  SalesHub-Lead to Opportunity Process. My script as below:
 
//====================================================
 
function onLoadSetDefaultBPF(executionContext) {
 
    debugger;
 
    var formContext = executionContext.getFormContext();
 
    var activeProcessName = formContext.data.process.getActiveProcess().getName();
 
    if (activeProcessName == null || activeProcessName !== 'SalesHub - Lead to Opportunity Process') {
 
        var parameters = {};
 
        parameters['process'] = 'SalesHub - Lead to Opportunity Process';
       
        Xrm.Navigation.openForm(/lead/, null, parameters);
    }
}
 
//===================================================
 
Implemented webresource  in SaleHub-Lead form, it's not working. The error message:
 
One of the scripts for this record has caused an error. For more details, download the log file.

Cannot read properties of null (reading 'getName')
Session Id: 3325fc28-9410-45cd-80e4-
Correlation Id: 73e0c609-e108-4194-aaee-
Event Name: onload
Function Name: onLoadSetDefaultBPF
Web Resource Name: SaleHub_lead_setdefaultBPFbasedonapp.js
Solution Name: Active
 
 
Could you please help to check what problem I have made?
 
Thanks!
I have the same question (0)
  • Inogic Profile Picture
    748 on at
    Hi,

    If you want to display the custom BPF process then check the below code –

    setDefaultBPFForOpportunity = function (executionContext) {
                var functionName = "onChange ";
                var formContext;
                var quantity;
                var pricePerUnit;
               
                    if (CRM_BPFLib.isValid(executionContext) && CRM_BPFLib.isValid(executionContext.getFormContext)) {
                        formContext = executionContext.getFormContext();
                        var activeProcessID = formContext.data.process.getActiveProcess().getId();
                        if (formContext != null) {
                            formContext.data.process.setActiveProcess("3E8EBEE6-A2BC-4451-9C5F-B146B085413A", CRM_BPFLib.callBackFunction);
                        }
                    }
                    ;
               
            };
    callBackFunction = function (result) {
                if (result == "success") { }
                else { }
            };

    Add your process ID in the ‘setActiveProcess’ method.


    Hope this helps.
     
    Thanks!
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    Please check if there is an active BPF in the current entity, if not the value obtained via the getActiveProcess() method is null.
     
    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

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

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans