- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2022 11:20 PM
Hi All,
Below is my requirement,
i have a request to close RITM's related to particular service.
In that service i have a field like date. if user selected the date last 4days i didn't choose those RITM's.
My request is in every RITM i have tasks more than 5. If at least 1 task is closed incomplete in that case i need to update RITM state as Closed incomplete. same like all tasks complete i need to update RITM state as Completed.
Can any one provide guidance on this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:29 AM
You can write fix script as below.
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery("");// give the encoded query here for your RITMs
gr.query();
while (gr.next()) {
var comp_count = 0;
var incomp_count = 0;
var sc = new GlideRecord('sc_task');
sc.addQuery('request_item', gr.sys_id);
sc.query();
var count = sc.getRowCount();
while(sc.next())
{
if(sc.state == '4') //give backend value of closed incomplete in sc task
{
incomp_count += 1;
}
else if(sc.state == '3') //give backend value of closed complete in sc task
{
comp_count += 1;
}
}
if(incomp_count > 0)
{
gr.state = '4'; //give backend value of closed incomplete in RITM
gr.update();
}
if(comp_count == count)
{
gr.state = '3'; //give backend value of closed complete in RITM
gr.update();
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:29 AM
You can write fix script as below.
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery("");// give the encoded query here for your RITMs
gr.query();
while (gr.next()) {
var comp_count = 0;
var incomp_count = 0;
var sc = new GlideRecord('sc_task');
sc.addQuery('request_item', gr.sys_id);
sc.query();
var count = sc.getRowCount();
while(sc.next())
{
if(sc.state == '4') //give backend value of closed incomplete in sc task
{
incomp_count += 1;
}
else if(sc.state == '3') //give backend value of closed complete in sc task
{
comp_count += 1;
}
}
if(incomp_count > 0)
{
gr.state = '4'; //give backend value of closed incomplete in RITM
gr.update();
}
if(comp_count == count)
{
gr.state = '3'; //give backend value of closed complete in RITM
gr.update();
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 01:48 AM
Hi Sumanth,
It's working only for the tasks related to closed incomplete and not supporting closed once.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 02:05 AM
For closed complete,
It will work if all the sc tasks under that RITM are closed.
Even if one of the sc task is not closed complete then it will not update.
If that is not your requirement, share your recent code and the exact requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 02:34 AM
Ha Sumanth it's working. i given working written number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2023 05:09 AM
Hi Sumanth,
Can we use it in BR.
Thanks,
Sharad