How to update the child table records using Async business rule with the state conditions?

Community Alums
Not applicable
By the below code based on the parent table(incident) I'm trying to update the "incident_child" table record but its not getting updated.
Note: This is "Async" Business rule and condition is State changes to "closed incomplete"

var
grTrans = new GlideRecord('incident');
    grTrans.addQuery('demand', demand);
    grTrans.query();
    if(grTrans.next()){
        var transID = grTrans.sys_id;
        var grTransTask = new GlideRecord('incident_child');
        grTransTask.addQuery('parent',transID);
        grTransTask.addEncodedQuery('stateNOT IN3,4');
        grTransTask.query();
        while(grTransTask.next()){
                grTransTask.setValue('state',4);
                grTransTask.setWorkflow(false);
                grTransTask.update();
           
        }
    }
4 REPLIES 4

Sujatha V M
Kilo Patron
Kilo Patron

@Community Alums 

 

Do you refer Incident task [incident_task] table? As far as I know there is no table as incident_child in OOB. 

 

Pleaser refer the below link for the cascading of state, 

 

https://www.servicenow.com/community/itsm-forum/auto-close-incident-when-incident-tasks-are-closed/m-p/506333

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Community Alums
Not applicable

Yes correct, we don't have incident_child table, just for a use case I mentioned that. So as per the above scripting I replaced the table name as a "incident & incident_child" but the actual table is our own custom one.

@Community Alums  Thank you for reverting on it. Glad to help you. 

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums Do you have a demand column defined on incident table? I can't find the same column in out of the box implementation?