Skip to main content

Notifications

Dynamics 365 Community / Forums / Sales forum / Web resource method do...
Sales forum
Suggested answer

Web resource method does not exist - Switching BPF

Posted on by 7
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'.");
        }
    }
};
 
  • Suggested answer
    CU20061741-0 Profile Picture
    CU20061741-0 7 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
    jameson1 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
    AM-12060339-0 7 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'.");
            }
        }
    };


     
  • 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
    AM-12060339-0 7 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
    AM-12060339-0 7 on at
    JS - web resource method does not exist

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,781 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,348 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans