- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2023 10:07 AM - edited ‎07-17-2023 11:00 AM
I am trying to add an extensible script to the IncidentUtils to change the default condition for the "Reopen Incident" UI Action. Please help me what am I doing wrong because it is not working?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2023 12:04 PM - edited ‎07-17-2023 12:57 PM
Since you're not defining your new function within the class, you'll want to call it like a static function instead (ex: IncidentUtils.canReopenIncident()). You also shouldn't need "global." unless you're calling it from a scoped app. And you can drop line 23 in your function where you're initializing incidentUtils since you're not actually using that anywhere in the function.
Here is an OOB example using the static "isCreateChildIncidentEnabled" function defined in that same Script Include. Just replace "isCreateChildIncidentEnabled" with your own function name, "canReopenIncident".
Alternatively, you could move your function definition to the class (just under the comment at line 6) and call it the same way you are calling it currently (minus the "global." if the UI Action is in Global).
var IncidentUtils = Class.create();
IncidentUtils.prototype = Object.extendsObject(IncidentUtilsSNC, {
initialize: function() {
IncidentUtilsSNC.prototype.initialize.call(this);
},
/***************Custom changes****************/
canReopenIncident: function(current) {
return current.incident_state == IncidentState.RESOLVED;
},
type: 'IncidentUtils'
});
IncidentUtils.isCopyIncidentEnabled = function(current) {
var incidentUtils = new IncidentUtils();
return incidentUtils.isCopyIncidentFlagValid();
};
IncidentUtils.isCreateChildIncidentEnabled = function(current) {
var incidentUtils = new IncidentUtils();
return incidentUtils.isCreateChildIncidentFlagValid();
};
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2023 12:04 PM - edited ‎07-17-2023 12:57 PM
Since you're not defining your new function within the class, you'll want to call it like a static function instead (ex: IncidentUtils.canReopenIncident()). You also shouldn't need "global." unless you're calling it from a scoped app. And you can drop line 23 in your function where you're initializing incidentUtils since you're not actually using that anywhere in the function.
Here is an OOB example using the static "isCreateChildIncidentEnabled" function defined in that same Script Include. Just replace "isCreateChildIncidentEnabled" with your own function name, "canReopenIncident".
Alternatively, you could move your function definition to the class (just under the comment at line 6) and call it the same way you are calling it currently (minus the "global." if the UI Action is in Global).
var IncidentUtils = Class.create();
IncidentUtils.prototype = Object.extendsObject(IncidentUtilsSNC, {
initialize: function() {
IncidentUtilsSNC.prototype.initialize.call(this);
},
/***************Custom changes****************/
canReopenIncident: function(current) {
return current.incident_state == IncidentState.RESOLVED;
},
type: 'IncidentUtils'
});
IncidentUtils.isCopyIncidentEnabled = function(current) {
var incidentUtils = new IncidentUtils();
return incidentUtils.isCopyIncidentFlagValid();
};
IncidentUtils.isCreateChildIncidentEnabled = function(current) {
var incidentUtils = new IncidentUtils();
return incidentUtils.isCreateChildIncidentFlagValid();
};
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2023 12:48 PM
There should be a colon instead of the equal sign but it worked.
canReopenIncident : function(current) {