Hello,
For a client I am trying to force to activate the standard Opportunity Sales Process when a lead is qualified (and an opportunity is created). I tried using the WorkflowTools solution, but this only works a few times before doing nothing again (even though the workflow states it is succeeded).
So now I am trying to force to activate this Opportunity Sales Process using the following method: https://powerobjects.com/tips-and-tricks/business-process-flows-switch-bpf-dynamics-365-javascript/
Since I constantly received the error 'Webresource method does not exist', I copied the name of the function of another javascript I have running (that actually works). This is the script I have created:
function FieldChange_OnChange(executionContext){
var formContext = executionContext.getFormContext();
var oppTopic = formContext.getAttribute(“name”).getValue();
var oppType = formContext.getAttribute(“mkb365_voortgekomenuitlead”).getText();
var activeProcessID = formContext.data.process.getActiveProcess().getId();
if (oppTopic != null) {
if (oppType == “Ja” && activeProcessID.toUpperCase() != “3E8EBEE6-A2BC-4451-9C5F-B146B085413A”) formContext.data.process.setActiveProcess(“3E8EBEE6-A2BC-4451-9C5F-B146B085413A”, callBackFunction);
}
};
function callBackFunction(result) {
if (result == “success”) {} else {}
When a lead is qualified, I have a workflow that automatically sets the field 'mkb365_voortgekomenuitlead' to 'Ja'. In the javascript I am using this field as a condition to activate the business process flow.
I have added this script to the form and the Event Handlers of the form. It didn't do anything. No response whatsoever. So then I added the javascript to the field itself (OnChange). The problem is: it doesn't do anything at all. No errors, no business process flow, nothing.
I am not really familiar with Javascripts, so I am probably doing something wrong. Could anyone please help me with this? Or maybe there is another way to activate the Opportunity Sales Process automatically?
Thank you in advance!