How to update RITM state based on Task State.

Rama26
Tera Contributor

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?

 

1 ACCEPTED SOLUTION

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

View solution in original post

9 REPLIES 9

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

Hi Sumanth,

It's working only for the tasks related to closed incomplete and not supporting closed once.

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.

 

 

Ha Sumanth it's working. i given working written number.

Hi Sumanth,

Can we use it in BR.

Thanks,

Sharad