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 :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Switching BPFs in same entity

(0) ShareShare
ReportReport
Posted on by 153

I have created two BPFs in the same entity and I want to switch BPF according to my selection in a choice field in the form.

6278.choice.jpg

I am also defining the event handler as on save option.

And my js code which I am using

function onLoadChangeBPFByType(executionContext) {
var formContext = executionContext.getFormContext();
var oppType = formContext.getAttribute(“casetypecode”).getText();
var activeProcessID = formContext.data.process.getActiveProcess().getId();
if (oppType == “Wildfire Case” && activeProcessID.toUpperCase() != “0ffbcde4-61c1-4355-aa89-aa1d7b2b8792”) formContext.data.process.setActiveProcess(“0ffbcde4-61c1-4355-aa89-aa1d7b2b8792”, callBackFunction);
};
function callBackFunction(result) {
if (result == “success”) {} else {}
}

And the error which I am getting is

ReferenceError: Web resource method does not exist: onLoadChangeBPFByType

Error Details:
Event Name: onsave
Function Name: onLoadChangeBPFByType
Web Resource Name: cr7af_SwitchBPF.js
Solution Name: Active
Publisher Name: DefaultPublisherorg6de6fc86

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    HI,

    Please check if you have any syntax error in your JS code. Please copy all code from cr7af_SwitchBPF.js and check the syntax using below online tool.

    esprima.org/.../validate.html

    I have updated your code to use correct double quotes ("")

    function onLoadChangeBPFByType(executionContext) {

    var formContext = executionContext.getFormContext();

    var oppType = formContext.getAttribute("casetypecode").getText();

    var activeProcessID = formContext.data.process.getActiveProcess().getId();

    if (oppType == "Wildfire Case" && activeProcessID.toUpperCase() != "0ffbcde4-61c1-4355-aa89-aa1d7b2b8792") formContext.data.process.setActiveProcess("0ffbcde4-61c1-4355-aa89-aa1d7b2b8792", callBackFunction);

    };

    function callBackFunction(result) {

    if (result == "success") {} else {}

    }

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Prashant.ITT Profile Picture
    153 on at

    Still getting same error:

    Web resource method does not exist: onLoadChangeBPFByType

    Session Id: 85cc93e4-63d0-42ff-b3dd-f47d933cd054

    Correlation Id: 0083fe83-3f17-4176-aea3-6a86b4523614

    Event Name: onload

    Function Name: onLoadChangeBPFByType

    Web Resource Name: cr7af_SwitchBPF.js

    Solution Name: Active

    Publisher Name: DefaultPublisherorg6de6fc86

    Time: Wed Mar 09 2022 17:25:45 GMT+0530 (India Standard Time)

  • Nya Profile Picture
    29,064 on at

    Hi Prashant Kumar,

    According to the error message, it seems that the function does not correspond to the JS web resource.

    Would you please share the screenshot of the form libraries and Event Handlers in the Form properties?

    Is it set as an OnLoad event or an OnSave event? Why the event name are different in both of the error messages you provided?

  • Prashant.ITT Profile Picture
    153 on at

    Form-Properties.jpg

  • Suggested answer
    Nya Profile Picture
    29,064 on at

    Hi,

    As you need to switch the BPF when you changed the value of the case type, it is recommended to set the event as an OnChange event.

    Column OnChange Event in model-driven apps - Power Apps | Microsoft Docs

    pastedimage1646905543860v2.png

    And the Process Id gotten in your code snippet could be null if there is no active process in the form.

    var activeProcess = Xrm.Page.data.process.getActiveProcess();
    if (activeProcess != null){
        if (oppType == "Wildfire Case" && activeProcessID.toUpperCase() != "0ffbcde4-61c1-4355-aa89-aa1d7b2b8792"){ 
            formContext.data.process.setActiveProcess("0ffbcde4-61c1-4355-aa89-aa1d7b2b8792", callBackFunction);
        }
    }

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    Can you share entire code from SwitchBPF.js?

    Are you using any namespace in your code?

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Prashant.ITT Profile Picture
    153 on at

    function onLoadChangeBPF() {

    var oppType = Xrm.Page.data.process.getAttribute("casetypecode").getText();

    var activeProcess = Xrm.Page.data.process.getActiveProcess();

    if (activeProcess != null){

       if (oppType == "Wildfire Case" && activeProcessID.toUpperCase() != "0ffbcde4-61c1-4355-aa89-aa1d7b2b8792"){

           Xrm.Page.data.process.setActiveProcess("0ffbcde4-61c1-4355-aa89-aa1d7b2b8792", callBackFunction);

       }

    }

    function callBackFunction(result) {

    if (result == "success") {} else {}

    }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 60 Most Valuable Professional

#2
11manish Profile Picture

11manish 23 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 10

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans