- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 02:55 AM
Hello!
I have a requirement to check the catalog tasks created from an RITM.
If there is only one catalog task, do something.
If there is more than one catalog task and all are open, thrown an error message.
If there is more than one catalog task and are are closed, do something.
Is this possible?
Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 04:05 AM
hello
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
if(gr.getRowCount()==1)
{
//write the code to create an incident record
current.state=closed skipped state value;
current.update();
}
else if(gr.getRowCount()>1)
{
while(gr.next())
{
if(gr.state==open_state_value)
{
gs.addErrorMessage('There is a open catalog task');
current.setAbortAction(true);
}
else if(gr.state==close_state_value)
{
//write your code to insert the incident
current.state=closed skipped state value;
current.update();
}
}
}
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 02:20 AM
This worked!
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 01:39 AM
Hi, it is possible, you should try glide agregade
i leave you some some usefull links
https://developer.servicenow.com/blog.do?p=/post/glideaggregate/
https://docs.servicenow.com/en-US/bundle/tokyo-application-development/page/script/glide-server-apis/topic/p_GlideServerAPIs.html