web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Web resource method does not exist - Switching BPF

(1) ShareShare
ReportReport
Posted on by 9
Hitting an error here: web resource method does not exist. 
 
Appears the code is ok but I could be missing something here!
 
I am attemtping to switch Business Process Flows using a drop down selection field 
 
Code: (updated)
 
 

 

code updated: error still there
 
 
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'.");
        }
    }
};
 
I have the same question (0)
  • Suggested answer
    Stitti Profile Picture
    23 on at
    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.
  • jameson1 Profile Picture
    7 on at
    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 -
     
    function checkSwitchBPFbyType(executionContext){
    // Add the logic
    }
     
  • AM-12060339-0 Profile Picture
    9 on at
    JS - web resource method does not exist
    code updated: error still there
     
     
    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'.");
            }
        }
    };


     
  • Prathibha Lakhotia Profile Picture
    on at
    JS - web resource method does not exist
    Please check all curly brackets are closed -- copy in Visual Studio js file and update
  • AM-12060339-0 Profile Picture
    9 on at
    JS - web resource method does not exist
    updated function: still has error!
     

    One of the scripts for this record has caused an error. For more details, download the log file.

  • AM-12060339-0 Profile Picture
    9 on at
    JS - web resource method does not exist

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans