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.
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
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 {}
}
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/
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
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); } }
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?
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)
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.
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/
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,912 Super User 2024 Season 2
Martin Dráb 229,355 Most Valuable Professional
nmaenpaa 101,156