I tried the best Practice posted here: https://www.ibm.com/developerworks/community/blogs/a9ba1efe-b731-4317-9724-a181d6155e3a/entry/best_practices_for_customizing_maximo_anywhere_javascript?lang=en for customizing the StatusChangeHandler.commitWOStatusChange function.
Took a copy of the original function as described:
var originalCommitWOStatusChange = StatusChangeHandler.commitWOStatusChange
Then wanted to use it as such:
commitWOSTatusChange: function(eventContext) {
if(conditionsAreFalse) {
Message to User to Fix Conditions;
}
else {
originalCommitWOStatusChange(eventContext);
}
Essentially I want to ensure they are allowed to perform the status change according to custom conditions (Worklog entered as an example).
However when the framework hits my code, it immediately executes the original function without testing my conditions. It seems the variable to store the function causes it to run and ignore the rest of my code.
Am I doing this in the right manner or do we need to follow a different process to control the running of the change status?
If I remove the variable I can get it to hit my code but calling the original function directly after this fires out errors.
Thanks
Bill
our Application Handlers are Dojo "declare" classes so they have to be overridden differently than other Javascript files.
Here's an example class that overrides the existing StatusChangeHandler.js method.
define("application/handlers/ExtendedStatusChangeHandler",
[ "dojo/_base/declare",
"application/handlers/StatusChangeHandler",
],
function(declare, StatusChangeHandler) {
return declare( StatusChangeHandler, {
/**
* Commit changes to WO Status (handle OK button clicked)
* @function
* @param {string} eventContext - javascript variables context.
*/
commitWOStatusChange: function(eventContext){
if (true)
console.error("Custom WO Status Change");
else {
this.inherited(arguments);
}
},
});
});
You need to replace your references to StatusChangeHandler in your app.xml with this ExtendedStatusChangeHandler to get it to be loaded by the app.