how to display change request number in ritm description filed once change request is created

Arjun Reddy Yer
Mega Sage

Can anyone help me @Vasantharajan N @Ankur Bawiskar 

 

As I need to display change request number in ritm description filed once change request is created

Tried with Business Rule and the condition is when the change state is in New. 

But not able to get the Change Request number.

 

Business Rule: 

var chnGr_sysId = current.change_request.toString();
var riTs = new GlideRecord('sc_req_item');
riTs.addQuery('parent', chnGr_sysId);
riTs.addActiveQuery(); 
riTs.query();
if (riTs.next()) {

    riTs.description = current.number.toString(); 
    chGr.update();

}

 

1 ACCEPTED SOLUTION

@Arjun Reddy Yer - Please try this code and let us know.

var chnGr_sysId = current.sys_id.toString();
var riTs = new GlideRecord('sc_req_item');
riTs.addQuery('parent', chnGr_sysId);
riTs.addActiveQuery();
riTs.query();
if (riTs.next()) {
    riTs.description = current.number.toString();
    riTs.setWorkflow(false);
    riTs.update();
}

 


Thanks & Regards,
Vasanth

View solution in original post

21 REPLIES 21

Vasantharajan N
Tera Sage
Tera Sage

@Arjun Reddy Yer -

small correction in your code change chGr.update() to riTs.update(); and try.

var chnGr_sysId = current.change_request.toString();
var riTs = new GlideRecord('sc_req_item');
riTs.addQuery('parent', chnGr_sysId);
riTs.addActiveQuery(); 
riTs.query();
if (riTs.next()) {

     riTs.description = current.number.toString(); 
     riTs.update();

 }

 


Thanks & Regards,
Vasanth

it's not working as I need to populate Change Request number in Description field

 

ArjunReddyYer_0-1683878991931.png

ArjunReddyYer_1-1683879043451.png

 

@Arjun Reddy Yer - 

Please try with this code. Line# 1 made change to get the sys_id of the current change request. 

var chnGr_sysId = current.sys_id.toString();
var riTs = new GlideRecord('sc_req_item');
riTs.addQuery('parent', chnGr_sysId);
riTs.addActiveQuery(); 
riTs.query();
if (riTs.next()) {

     riTs.description = current.number.toString(); 
     riTs.update();

 }

 


Thanks & Regards,
Vasanth

still not able to populate 

 

ArjunReddyYer_0-1683881150954.png

Business Rule:

 

var chnGr_sysId = current.sys_id.toString();
var riTs = new GlideRecord('sc_req_item');
riTs.addQuery('parent', chnGr_sysId);
riTs.addActiveQuery();
riTs.query();
if (riTs.next()) {

    riTs.description = current.number.toString();
    riTs.update();
}