- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 02:06 AM
Hi All,
Need to override
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 08:34 PM
try this
-
Create a Custom Script Include:
- Navigate to System Definition > Script Includes.
- Click on New to create a new script include.
- Name it something like
CustomKBCommonSNC
. - Extend the
KBCommonSNC
class.
-
Override the
getStateMessage
Method:- In your custom script include, override the
getStateMessage
method to return your custom message.
- In your custom script include, override the
Here's an example of how you can do this:
var CustomKBCommonSNC = Class.create();
CustomKBCommonSNC.prototype = Object.extendsObject(KBCommonSNC, {
getStateMessage: function(state) {
if (state == 'review') {
return "Your custom review message here";
}
return this._super(state);
}
});
- Update the Business Rule:
- Ensure your business rule calls the custom script include instead of the original
KBCommonSNC
.
- Ensure your business rule calls the custom script include instead of the original
var customKBCommon = new CustomKBCommonSNC();
var message = customKBCommon.getStateMessage(current.state);
gs.addInfoMessage(message);
This way, you avoid directly modifying the high-priority KBCommonSNC
script include and still achieve the desired customization.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 08:34 PM
try this
-
Create a Custom Script Include:
- Navigate to System Definition > Script Includes.
- Click on New to create a new script include.
- Name it something like
CustomKBCommonSNC
. - Extend the
KBCommonSNC
class.
-
Override the
getStateMessage
Method:- In your custom script include, override the
getStateMessage
method to return your custom message.
- In your custom script include, override the
Here's an example of how you can do this:
var CustomKBCommonSNC = Class.create();
CustomKBCommonSNC.prototype = Object.extendsObject(KBCommonSNC, {
getStateMessage: function(state) {
if (state == 'review') {
return "Your custom review message here";
}
return this._super(state);
}
});
- Update the Business Rule:
- Ensure your business rule calls the custom script include instead of the original
KBCommonSNC
.
- Ensure your business rule calls the custom script include instead of the original
var customKBCommon = new CustomKBCommonSNC();
var message = customKBCommon.getStateMessage(current.state);
gs.addInfoMessage(message);
This way, you avoid directly modifying the high-priority KBCommonSNC
script include and still achieve the desired customization.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader