- 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 04:05 PM
Your BR is not checking for Closed Complete state, is that correct ?
when you click th UI action Close Task, what is the expected change to the state? closed Complete ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2018 04:55 PM
It was checking for Closed Complete, Closed Incomplete and Closed Skipped, but I deselected closed complete.
The UI action Close Task was created before my time so I'm not sure what is the expected change, but I'm guessing it is closed complete (see below)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2018 05:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2018 10:26 AM
Hi Aman,
I deactivated the BR and submitted the request. No attachment was mandatory in the task and I had selected closed incomplete. After closing the task the RITM's state was closed complete.
I know you mentioned I have to include closed complete in the condition, but that is how I originally had it. I only want the attachment to be mandatory if it is closed complete, not closed incomplete/skipped.
Sorry if it sounds confusing!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2018 05:21 PM
I would highly suggest you add a custom True/False (Default value of "false") field to the Catalog Item table so you can control which items the BR should run on by just selecting the checkbox for the appropriate items. You would greatly simplify your condition and save yourself some potential grief if you rename an item that would no longer match your Short description filters.
And you should change the State filter to:
...so that the Business Rule runs only when the State is changing to Closed Complete.