Solution
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I have SI and onsubmit client script to validate attachment but every time even after attaching document, it is returning false.
here is SI :
var AttachmentChecker = Class.create();
AttachmentChecker.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
hasAttachment: function () {
var recordSysId = this.getParameter('sysparm_sys_id');
var tableName = this.getParameter('sysparm_table');
// Validate inputs
if (!recordSysId || !tableName) {
return 'false';
}
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', recordSysId);
gr.addQuery('table_name', tableName);
gr.setLimit(1);
gr.query();
return gr.hasNext() ? 'true' : 'false';
}
});
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22m ago - last edited 17m ago
Hello @Rahul11t1
Your Script Include is missing below:
return gr.hasNext() ? 'true' : 'false';
},
type: 'AttachmentChecker' // type property required for AJAX to work
});
and also ensure Client Callable is checked.
Additionaly, some best practices:
1. Use the variable name as camel notation like grAttach instead of gr.
2. You must add some logging initially in your script include just to find out it is executing successfully:
gs.log('AttachmentChecker - sysId: ' + recordSysId + ', table: ' + tableName);
Hope that helps!