Skip to main content

Notifications

Announcements

No record found.

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!
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Populate default business process flow onload form
    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
     
  • Inogic Profile Picture
    438 on at
    Populate default business process flow onload form
    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!

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,925 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans