- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2018 02:49 PM
Hello,
I currently have a business rule in place to make attachments mandatory before a task is closed. The requirements have changed and we only want it to be mandatory when it is closed complete. If the task is being closed "incompletely" or "skipped", the attachment should not be mandatory.
I already changed one of my conditions, which I changed from State is one of Closed Complete, Closed Incomplete, Closed Skipped to State is not one of Closed Incomplete, Closed Skipped. After the change the attachment is still mandatory, which makes me think it has to do with the Close Task button.
Any assistance with this would be greatly appreciated!
This is what I currently have:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 11:11 AM
Hi,
Change the condition,use this condition state is closed complete ,
and follow below code...Before (insert/update) BR
(function executeRule(current, previous /*null when async*/) {
var gr= new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id",current.sys_id);
gr.query();
if (!gr.hasNext()) {
gs.addErrorMessage("Attachment is required to submit this Request");
current.setAbortAction(true);
}
})(current, previous);
it will work perfectly..
Mark correct or helpful if it helps you.
Warm Regards,
Pranay Tiwari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2018 05:00 PM
Just something that stood out to me, when you changed the state condition in the BR from IS ONE OF (closed complete/incomplete/skipped) IS NOT ONE OF (closed incomplete/skipped) you are actually picking up ALL of the other state values. If it should only trigger on state is closed complete, then set state IS closed complete.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 11:11 AM
Hi,
Change the condition,use this condition state is closed complete ,
and follow below code...Before (insert/update) BR
(function executeRule(current, previous /*null when async*/) {
var gr= new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id",current.sys_id);
gr.query();
if (!gr.hasNext()) {
gs.addErrorMessage("Attachment is required to submit this Request");
current.setAbortAction(true);
}
})(current, previous);
it will work perfectly..
Mark correct or helpful if it helps you.
Warm Regards,
Pranay Tiwari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 02:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 02:19 PM
Reload the form and the state will go back to it's previous value. With set abort action it just stops the DB transaction. If you like, you can set current.state = previous.state just prior to the abort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 04:52 PM
Yes, thank you!