When a user submit the request, the RITM number should be autopopulated in the work notes.

priyanka58
Tera Contributor

When a user submit the request, the RITM number should be autopopulated in the work notes of that change request i.e. RITMXXXXXXXX is created.

18 REPLIES 18

Community Alums
Not applicable

Hi Priyanka,

You can achieve it using a Business rule, here is the code and configuration:

https://community.servicenow.com/community?id=community_question&sys_id=f36c4c23db02a3001089e15b8a96...

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Anand Shukla
Mega Guru

Hi,Priyanka 

You can use After insert Business rule for this.

write a On insert BR on sc_req_item.

find_real_file.png

and in the script :

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	
	var req = current.number;
	gs.log("myreq::"+req);

         

               current.work_notes = "Requested item : "+req;

               current.update();
})(current, previous);

 

find_real_file.png 

 

 

Please Mark it helpful or correct. 

So it could help others as well.

 

Thanks 

Anand Shukla

Hello,

But according to my requirement it should be populated in the work note of the change request form.

 

Regards,

Priyanka shukla

Alright, So if you need to capture the RITM in every change request or on any specific request so based on that you can change the script of BR and populate the work_notes of change.

Use the below Script: 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here

    var req = current.number;
    gs.log("myreq::" + req);

    var gr = new GlideRecord('change_request');
    gr.addQuery('sys_id','c83c5e5347c12200e0ef563dbb9a7190' );//your change re sys_id
   //gr.addQuery('sys_id',gs.getProperty('property name where you store your change request number sys_id') ); // recommended way to store sys id in property and use it
    gr.query();
    if (gr.next()) {
     gr.work_notes="Requested item : " + req;

  }
	gr.update();


   //

  
})(current, previous);

 

find_real_file.png

Mark it helpful and Correct.

Thanks and regards

Anand