- 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-13-2022 02:58 AM
Hello Ceraulo,
Yes this is possible.
Could you please let me know more deatils likewhen you want to show the message and things like that .
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 03:58 AM
Nayan,
I have a UI Action that creates an incident record from an RITM.
What I want to do is created the incident record if there is only one catalog task and closed skipped the RITM.
If there are many catalog tasks and at least one is open, it will not create the incident record but will show a message that there is an open catalog task.
If there are many catalog tasks and all are closed, create the incident and closed skipped the RITM.
Thank you
- 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 12:27 AM
It works when there is only one catalog task.
It doesn't if there are more than one catalog task., The error message is not displayed.
Is there another way to do the update?
Thank you.