Warning message that is displayed when trying to access a published knowledge article that has been checked out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 12:22 PM
Can anyone clarify what is producing the message that appears in the below image. This message is displayed when an existing published knowledge article is checked out for editing and a new version of the article is created and placed in a Draft state. When you view the published version of the article, this message is displayed to let you know that a new version has been created and edits must be done in the new draft version.
I see that there is a client script on the kb_knowledge table (Knowledge Article table) called “Versioning : Show messages”. And the script has the following code:
function onLoad() {
if(g_scratchpad.versioning.message){
g_form.addInfoMessage(g_scratchpad.versioning.message);
}
}
This script is definitely displaying the below message, but I can’t figure out where the variable g_scratchpad.versioning.message is being set. Any ideas? The reason that I am asking is that a similar message is displayed on the Service Portal side when a page containing the Form widget is viewed. The link should point to the Service Portal view of the draft article and not the SN backend view of the article. I would like to change the link if at all possible.
- Labels:
-
Knowledge Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 12:37 PM
Hi Lizb,
This message is coming from the business rule called "Versioning : Set scratchpad variables". I would not suggest to update it since OOB in the portal. If you see the same message and you click on the "An updated version of this article is available in the portal only it would route you to the new article. Kindly confirm if that works in the PDI.
Regards,
Deepankar Mathur

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 12:44 AM
As Deepankar mentioned, the business rule "Versioning : Set scratchpad variables" populates the g_scratchpad.versioning.message value.
It does this by referencing a script include called KBVersioning (API name global.KBVersioning) and using a function called getWarningMessage:
var versioning = new KBVersioning();
g_scratchpad.versioning.enabled = versioning.isVersioningEnabled();
g_scratchpad.versioning.message = versioning.getWarningMessage(current, current.getTableName()+".do?sys_id=");
KBVersioning extends the out of the box version of itself, which is called KBVersioningSNC (API name global.KBVersioningSNC).
KBVersioningSNC contains the getWarningMessage function definition:
/**
* Returns the message to be displayed in the view pages
*
* @param GlideRecord : current
* @param String : navigateTo (which view page link to use for navigation - Any of (kb_knowledge.do,kb_view.do))
*
* @return String
**/
getWarningMessage: function(current,urlPrefix){
var recordClass = current.sys_class_name;
if(current.article_id.nil())
return '';
var latest = this.getLatestAccessibleVersionFromId(current.article_id);
var workflowState = current.workflow_state;
var reviser = current.revised_by;
if(latest && latest.sys_id!=current.sys_id){
var link = urlPrefix + latest.sys_id;
if(latest.canWrite() || this.canCheckout(latest))
if(recordClass == 'kb_knowledge_block'){
link=link+"&sysparm_class_name="+current.sys_class_name;
return gs.getMessage("<a href='{0}'>An updated version of this block is available</a>. You can only edit the latest version of the block",link);
}
else
return gs.getMessage("<a href='{0}'>An updated version of this article is available</a>. You can only edit the latest version of the article",link);
else
if(recordClass == 'kb_knowledge_block')
return gs.getMessage("<a href='{0}'>An updated version of this block is available</a>",link);
else
return gs.getMessage("<a href='{0}'>An updated version of this article is available</a>",link);
}
else if((workflowState=="draft" || workflowState=="review") && !gs.nil(reviser) && this._isAuthor(current) && !current.canWrite()){
var reviserName = "another contributor";
if(reviser.name)
reviserName = reviser.name+"";
if(recordClass == 'kb_knowledge_block')
return gs.getMessage("This block cannot be edited, since it is already checked out by {0}.", reviserName);
else
return gs.getMessage("This article cannot be edited, since it is already checked out by {0}.", reviserName);
}
return '';
},
So it works out a value for "link" and then drops that into the message which is referenced from sys_ui_message (via gs.getMessage).
So to summarise we have:
- Client Script: Versioning : Show messages
- Business Rule: Versioning : Set scratchpad variables
- Script Include: KBVersioning
- Script Include: KBVersioningSNC
- function getWarningMessage
- sys_ui_message: <a href='{0}'>An updated version of this article is available</a>. You can only edit the latest version of the article
I think the reasonable point to extend or change the behaviour here would probably be to copy the getWarningMessage function from KBVersioningSNC into KBVersioning to override it, and then change the logic there. This leaves the original function intact in KBVersioningSNC, should you need to revert back to that at any point.