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'.");
}
}
};