The CreatorCon Call for Content is officially open! Get started here.

Populate RITM to the worknotes

Rushikesh5
Giga Guru

Hi All,

My requirement is like

1. If I open a change form and click on the order button [which I created by UI action]

2. Then it should redirect to the service portal to a particular item [This is done]

3. After the catalog item is requested then the RITM number should populate in the work notes of the change form i.e. for example RITMXXXX is created

Can you help me with this

Thanks,

Rushikesh

1 ACCEPTED SOLUTION

then update as this

action.setRedirectURL('sp?id=sc_cat_item&sys_id=119c3de01b02011014d099f7b04bcb02&sysparm_chg=' + current.sys_id);

Then have onLoad catalog client script on your catalog item

function onLoad(){
	var url = top.location.href;
	var chg = new URLSearchParams(url).get("sysparm_chg");
	g_form.setValue('variableName', chg);
}

Then have workflow run script

var chg = new GlideRecord('change_request');

if(chg.get(current.variables.variableName)){
	chg.work_notes = current.number + ' is created';
	chg.update();
}

You need to create text variable and hide it always on catalog form and RITM form as well

Regards
Ankur

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

View solution in original post

21 REPLIES 21

Hi,

I am trying this script and its half working as well 

Just that here I have to put the sys_id manually for a particular record that sys_id should auto-update for every record

(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);

please,Refer this link for more clarity

https://community.servicenow.com/community?id=community_question&sys_id=8ba4d0411b2a8510ed6c9979b04bcb29&anchor=answer_39b1248d1bea8510ed6c9979b04bcb96&view_source=searchResult

Hi,

that won't work as you are hard-coding the sysId

take the approach I mentioned and it would work fine

Regards
Ankur

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

Hi,

Okay. I will try your approach to this.

 

Thanks,

Rushikesh

Hi,

I tried what you said but it's not working

or can you explain to me all the steps in detail so that I could see if anything is missing

 

Thanks,

Rushikesh

 

Hi,

please share your UI action script which is redirecting

Regards
Ankur

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