Web resource method does not exist - Switching BPF
In the EventHandler in your screenshot, you have specified "SwitchBPF" as the method, but this is not the method but the name of your overlying object in which the method is nested.
To reference your method "checkSwitchBPFbyType" as an EventHandler, you must enter "SwitchBPF.checkSwitchBPFbyType" as the EventHandler.
This means that the "checkSwitchBPFbyType" method from your "SwitchBPF" object should be used as the EventHandler.
Web resource method does not exist - Switching BPF
I'm not a JS Expert. But it looks like the function name you have given in the Event handler is SwitchBPF while SwitchBPF in your code is a variable and not a function. Also the function checkSwitchBPFbyType is inside the SwitchBPF object.
Could you please try formatting the code like the following by removing the SwitchBPF variable and giving the function name in the event handler as checkSwitchBPFbyType and see if it works -
var SwitchBPF = { checkSwitchBPFbyType: function (executionContext) { // For example // End User Opportunity 100000000 | Process Flow End-User Opportunity : b919E14D1-6489-4852-ABD0-A63A6ECAAC5D // Distributor Onboarding 100000001 | Process Flow Distributor Onboarding: b1023688F-59CD-EE11-9079-000D3A794214 // Distributor Forecast 100000002 | Process Flow Distributor Forecast: b919E14D1-6489-4852-ABD0-A63A6ECAAC5D
var formContext = executionContext.getFormContext(); if (formContext.data.entity.getEntityName() === "opportunity") { if (formContext.data.process.getActiveProcess() !== null) { // Check Type & BPF match as required var currentBpfID = formContext.data.process.getActiveProcess().getId(); if (formContext.getAttribute("new_formtype")) { var leadType = formContext.getAttribute("new_formtype").getValue(); if (leadType === 100000000 && currentBpfID !== "b919E14D1-6489-4852-ABD0-A63A6ECAAC5D") { formContext.data.process.setActiveProcess("b919E14D1-6489-4852-ABD0-A63A6ECAAC5D", function () { console.log("BPF set to End User Opportunity"); }, function (error) { console.error("Error setting BPF: " + error.message); }); } else if (leadType === 100000001 && currentBpfID !== "b1023688F-59CD-EE11-9079-000D3A794214") { formContext.data.process.setActiveProcess("b1023688F-59CD-EE11-9079-000D3A794214", function () { console.log("BPF set to Distributor Onboarding"); }, function (error) { console.error("Error setting BPF: " + error.message); }); } else if (leadType === 100000002 && currentBpfID !== "b919E14D1-6489-4852-ABD0-A63A6ECAAC5D") { formContext.data.process.setActiveProcess("b919E14D1-6489-4852-ABD0-A63A6ECAAC5D", function () { console.log("BPF set to Distributor Forecast"); }, function (error) { console.error("Error setting BPF: " + error.message); }); } } else { console.warn("'new_formtype' attribute not found on the form."); } } else { console.warn("No active process found."); } } else { console.warn("Entity is not 'opportunity'."); } } };
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.