Hi Community!
I'm trying to add a function as an event handler for the OnPreStageChange event to check some conditions before a user moves an opportunity from one stage in the business process to another.
Getting the name of the active process is no problem, but using formContext.data.process.addOnPreStateChange to register my function has the error "formContext.data.process.addOnPreStateChange is not a function"
This is my code:
function () {
function writeToConsole(message)
{
if (typeof console != 'undefined') {
console.log(message);
}
}
// Code to run in the form OnLoad event
this.formOnLoad = function (executionContext) {
var formContext = executionContext.getFormContext();
writeToConsole("Process-Name: " + formContext.data.process.getActiveProcess().getName()); // <= works fine!!!
formContext.data.process.addOnPreStateChange( // <= error
function (executionContext) {
// check condition ...
writeToConsole("test");
}
);
}
}
Thanks in advance for any ideas or help!
Ecki