How to make attachment Mandatory for Approval in sysapproval_approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
How to make attachment mandatory approval table .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
in approver table attachment is not a field . So, code will search in sys_attachment table . When add a new attach in approval and try to submit the record this code will deny to submit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
why attachment is mandatory for approval?
What's your exact business requirement here?
Approvers only approve/reject request by looking into the RITM
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
as per the requirement this TPRM module table , approver needs to add attachment and additional comments while approve or reject
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @armanoj ,
I tested the script in my PDI and it worked as expected. In this scenario, you can use setWorkflow(false) to prevent the execution of other scripts while validating attachments. make sure it is not affecting other functionalities.
Set the source table to the TPRM module table name to ensure attachments are enforced only for the required tables.
Condition:
State changes to - Approved or Rejected AND
source table is "specify your TPRM table name"
Before (insert/update) Business rule:
If this response was helpful, please consider marking it as Correct and Helpful. You may mark more than one reply as an accepted solution.
Thanks,
Natraj Sankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @armanoj ,
Create a Before Update Business Rule on sysapproval_approver.
- Table:
sysapproval_approver - When:
Before - Update: Checked
- Advanced: Checked
- conditon
and script
(function executeRule(current, previous) {
// Check comments
var comments = current.comments.getJournalEntry(1);
if (gs.nil(comments)) {
gs.addErrorMessage('Comments are mandatory while approving or rejecting.');
current.setAbortAction(true);
return;
}
// Check attachments
var attGR = new GlideRecord('sys_attachment');
attGR.addQuery('table_name', 'sysapproval_approver');
attGR.addQuery('table_sys_id', current.sys_id);
attGR.setLimit(1);
attGR.query();
if (!attGR.hasNext()) {
gs.addErrorMessage('Attachment is mandatory while approving or rejecting.');
current.setAbortAction(true);
return;
}
})(current, previous);
If this response was helpful, please consider marking it as Correct and Helpful. You may mark more than one reply as an accepted solution.
thanks ,
tejas 😊