How to set dynamic data in UI message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 07:39 PM - edited 02-16-2025 07:40 PM
my requirement is to show the message The article <article number> has been retired. when article is retired but currently its showing Knowledge record not found
in the knowledge content widget there is this part in server script
else{
data.messages.INSUFFICIENT_PREVILEGES = gs.getMessage("You do not have sufficient privileges to access this knowledge item");
data.messages.RECORD_NOT_FOUND = gs.getMessage("Knowledge record not found");
}
i replace the 'Knowledge record not found' by using system ui messages key = 'Knowledge record not found' and message 'The article {0} has been retired' but {0} should be dynamic showing the current knowledge article number
How to do this without modifying the widget server script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 08:51 PM
Hi @joyceelynn
Can you verify the following client script:
this script will assist you to inject into the widget's page.
function onLoad() {
var message = data.messages.RECORD_NOT_FOUND;
if (message.indexOf('Knowledge record not found') !== -1 && data.article_retired) {
var articleNumber = data.article_number;
data.messages.RECORD_NOT_FOUND = gs.getMessage('The article {0} has been retired', [articleNumber]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 09:06 PM
Hi @Community Alums I got this error 'The object "gs" should not be used in client scripts.' when trying to create this client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 09:24 PM
Hi @joyceelynn
Use following script to manage the msg.
var message = 'The article ' + articleNumber + ' has been retired';
g_form.showFieldMsg('field_name', message, 'error');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 09:10 PM
Hi @joyceelynn ,
I believe we must have to pass parameter in the method to render dynamically
gs.getMessage('key',parameters);
hence it require to modify server script.
Regards,
Krishnamohan