Updating RITM when related CHG updates

yasserbouat
Tera Guru

Hello experts,

I created a business rule that creates automatically a “change request” from RITM.
Then I created another business rule that does the following : when the change request state changes to “assess” , the related RITM updates to “work in progress” : the problem is my script is not working : when I update a chg request, the related RITM didn't get updated ! I tried to fix it with chatgpt but it didn't work : 

yasserbouat_0-1742392102431.png

 

 

(function executeRule(current) {

    
    if (current.state == 3) {

        var ritm = new GlideRecord('sc_req_item');
        
        ritm.addQuery('sys_id', current.parent);  
        ritm.query();

        if (ritm.next()) {
            ritm.state = 2;  
            ritm.update();
          
        } else {
            gs.error('RITM not found ' + current.sys_id); 
        }
    }

})(current);

 

 

1 ACCEPTED SOLUTION

Hi @yasserbouat 

add this code :

chg.parent = current.sys_id;

after - chg.priority = current.variables.v_priority.toString();

Then try to test it and check it parent field on change request form is updated or no.

View solution in original post

13 REPLIES 13

Hi @yasserbouat 

add this code :

chg.parent = current.sys_id;

after - chg.priority = current.variables.v_priority.toString();

Then try to test it and check it parent field on change request form is updated or no.

@Dhana3 

I added the line as you suggusted, and I create a request and I opend the xml and I found the parent, then i updated the change state to assess, but the related RITM didn't get updtaed ! and i also noticed an error on the portal : 

yasserbouat_0-1742400334880.pngyasserbouat_1-1742400387935.pngyasserbouat_2-1742400406199.pngyasserbouat_3-1742400432962.png

 



Hi @yasserbouat ,

 

This issue is with your change model configuration. But that is a different issue.

 

Please check this documentation - https://www.servicenow.com/docs/bundle/yokohama-it-service-management/page/product/change-management...

 

I suppose you are new to ServiceNow development. I suggest you to do through the documentation and learn about scripting. It is not that difficult.

All the best!

 

Regards,

Dhanashree

 

yasserbouat
Tera Guru

@Dhana3 

This is what I got : can you please show what should i do in order to make my script functions : 

 

<order/>
<outside_maintenance_schedule>false</outside_maintenance_schedule>
<parent/>
<phase>requested</phase>

yasserbouat_0-1742397073873.png