- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 05:21 AM
I am new to scripting.
I want to have a business rule that prevents Requested Item record from closing if Catalog task is NOT in closed complete state
Thank you kindly,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 09:56 AM
try this
var gr = new GlideRecord('sc_task');
gr.addQuery('requested_item', current.sys_id);
gr.addEncodeQuery('state=1^ORstate=2');
gr.addActiveQuery();
gr.query();
if (gr.next())
{
gs.addErrorMessage('There are open task records for this requested item. Please close all tasks.');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 06:04 AM
Not every catalog tasks generated out of an RITM needs to be set to Closed Complete, Few may be set to Closed Incomplete or Cancelled.
What should happen then.
I would consider creating the restricting business rule only when the tasks are open or work in progress state.