Verify Attachment Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 01:26 AM - edited 07-23-2024 02:00 AM
Hello experts,
I have a request to do the following requirement for kb_knowledge table.
I created an onLoad client script Name: Verify Attachment Record
Action:
- When the article is checked out and the version is a new version and the article has an attachment set the
Attachment Reviewed field to mandatory.
- When the article checked out and the Attachment Reviewed checkbox is set to true and there is an attachment on the knowledge article, set the checkbox to false and mandatory.
But the following client script and script include are not working, kindly advise on how to make it work. Thanks in advance.
Client script:
Script include:
isLatestVersion: function(articleSysId) {
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_id', articleSysId);
gr.orderByDesc('version');
gr.setLimit(2); // Get the current and the next version
gr.query();
if (gr.next()) {
var currentVersion = gr.getValue('version');
if (gr.next()) { // Move to the next record, if it exists
var nextVersion = gr.getValue('version');
return currentVersion > nextVersion; // current version is the highest
}
return true; // No next version found, current is the latest
}
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 03:39 AM
What kind of field is your custom field?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark