How to make attachments mandatory on SC Task based on variable condition

rakshith_shetty
Tera Contributor

I have a requirement to make attachment mandatory on SC Task Table  if One of the variable  value is Yes on a SC_TASK Table

 

I Have created a Before Business rule to make it mandatory , script is working fine , but i am not able to fetch the variable value with the below script 

 

(function executeRule(current, previous /*null when async*/ ) {
var va = current.variable_pool.netstat_report;
current.addInfoMessage('Testing Catalog ' + va);
if (va == 'yes') {

var sctaskAttach = new GlideRecord('sys_attachment');
sctaskAttach.addQuery('table_sys_id', current.sys_id);
sctaskAttach.query();
if (!sctaskAttach.hasNext()) {
gs.addErrorMessage('Attachment is empty Please attach ');
current.setAbortAction(true);
}
}
})(current, previous);

5 REPLIES 5

Share the screenshot of BR with "when to run" condition


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution