How to write UI action script to bring RITM variables to change request description?

Dakarapu Ramya1
Kilo Contributor

Hi all,

We have a requirement whenever user clicks on new change request in related list from RITM  for normal , emergency change variables on RITM should get populated in description.

find_real_file.png

I tried using the script on OOB UI action but no result , Can anyone help with the script:

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

then use display business rule on change_request and same script

it will work

var ritm = new GlideRecord('sc_req_item');
ritm.get(current.getValue('parent'));

var arr = [];
var variables = ritm.variables.getElements(); 
for (var i=0;i<variables.length;i++) { 
	var question = variables[i].getQuestion();
	var label = question.getLabel();
	var value = question.getDisplayValue();
	if(label != '' && value != ''){
		arr.push(label + ":" + value + "");
	}
}
current.description = arr.join('\n');

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

19 REPLIES 19

Rajat_Choudhary
Tera Expert

Hi Dakarapu,

There is typo error at last line action.setRedirectURL(urs.toString()+"");.

Thanks,

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

Hi @Rajat_Choudhary 

I even tried correcting that typo error , but no result.

Kind Regards,

Ramya.

Hi Ramya,

You want the description of new Change Request ,to get populated with RITM fields .

Is my understanding correct?

Hope this answers will be helpful.
Please mark the answer as helpful and correct.

Best Regards,
Rajat Choudhary

Hi

Yes .It should be done only for normal and emergency.

Now it is taking directly for normal change.