Active field in requested item is not changing to false , When state is closed complete .

nameisnani
Mega Sage

Hi All ,

 

I am facing the below issue in my ServiceNow instance wherein the status of the field Active of the RITM's  sometimes are not changing to false when the state is 'Closed completed'  because of which the RITM's are showing up in service portal widget' My request' Closed Complete' option . 


Any suggestions on this/ or anyone has faced similar issue.


I feel writing a business rule on RITM table will work , however wanted to understand why its happening when for the same catalog item.

 

can anyone please root cause for this . 

 

SunilKumarPadh_0-1690961918014.png

SunilKumarPadh_1-1690961927305.png

 

 

@ServiceNow10sun 

 

3 ACCEPTED SOLUTIONS

BharathChintala
Mega Sage

@SunilKumar Padh  can you check any catalog tasks are open under those req items??

and also no need to write business rule there is already one oob provided for this.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

nameisnani
Mega Sage

HI @Harshal Aditya  & @BharathChintala 

 

Thanks for the reply .

 

where i need to update in OOB business rule .

could you please suggest here .

 

SunilKumarPadh_0-1690967781989.png

 

condition - 

current.stage.changes() && (current.stage=="complete" || current.stage=="Request Cancelled" || current.stage=="closed_incomplete" || current.stage=="closed_skipped")

Script - 

(function executeRule(current, previous /*null when async*/ ) {
    current.active = false;
    // Delivery Plan Specific, update the state here, so that TaskStateUtil, won't be able set the state.
    if (!current.delivery_plan.nil()) {
        if (current.stage == 'closed_incomplete' || current.stage == 'Request Cancelled')
            current.state = 4;
        else if (current.stage == 'closed_skipped')
            current.state = 7;
    }

    // If we started a workflow for this item, cancel it
    if ((current.stage == 'Request Cancelled') && current.context && !current.context.nil()) {
        var w = new Workflow();
        var gr = new GlideRecord('wf_context');

        if (gr.get(current.context))
            w.cancelContext(gr);
    }

})(current, previous);

 

can anyone please provide me the updated script . 

 

Thanks in Adavance

 

@Ravi Chandra_K 

View solution in original post

make the OOB inactive and create similar BR with Modified Advanced Conditions.

Or else Modify the Workflow being used by your Request Item so that the Stage is set to one of the expected values. (E.g. complete, Request Cancelled, closed_incomplete or closed_skipped)

Please hit the thumb and Mark as correct if it helped!

Kind Regards,

Ravi Chandra

View solution in original post

10 REPLIES 10

Harshal Aditya
Mega Sage
Mega Sage

Hi @nameisnani ,

 

I also faced this similar kind of issue.

There is a OOB BR on sc_req_item table - "Set Active Flag"

 

You need to update the BR or create a new one

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

BharathChintala
Mega Sage

@SunilKumar Padh  can you check any catalog tasks are open under those req items??

and also no need to write business rule there is already one oob provided for this.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

nameisnani
Mega Sage

HI @Harshal Aditya  & @BharathChintala 

 

Thanks for the reply .

 

where i need to update in OOB business rule .

could you please suggest here .

 

SunilKumarPadh_0-1690967781989.png

 

condition - 

current.stage.changes() && (current.stage=="complete" || current.stage=="Request Cancelled" || current.stage=="closed_incomplete" || current.stage=="closed_skipped")

Script - 

(function executeRule(current, previous /*null when async*/ ) {
    current.active = false;
    // Delivery Plan Specific, update the state here, so that TaskStateUtil, won't be able set the state.
    if (!current.delivery_plan.nil()) {
        if (current.stage == 'closed_incomplete' || current.stage == 'Request Cancelled')
            current.state = 4;
        else if (current.stage == 'closed_skipped')
            current.state = 7;
    }

    // If we started a workflow for this item, cancel it
    if ((current.stage == 'Request Cancelled') && current.context && !current.context.nil()) {
        var w = new Workflow();
        var gr = new GlideRecord('wf_context');

        if (gr.get(current.context))
            w.cancelContext(gr);
    }

})(current, previous);

 

can anyone please provide me the updated script . 

 

Thanks in Adavance

 

@Ravi Chandra_K 

make the OOB inactive and create similar BR with Modified Advanced Conditions.

Or else Modify the Workflow being used by your Request Item so that the Stage is set to one of the expected values. (E.g. complete, Request Cancelled, closed_incomplete or closed_skipped)

Please hit the thumb and Mark as correct if it helped!

Kind Regards,

Ravi Chandra