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

Copy RITM Requested for to REQ Requested for

Jacob23
Mega Guru

Hi, Thanks for taking the time to read.

I have an issue where some workflows do not fill our the REQ requested for but will fill out the RITM requested for.  There is more than one workflow so I was looking to create a business rule to catch all of this.

You can see below the request.requested_for is not populated.

find_real_file.png

I have tried to create a business rule to run after a record is inserted but I cannot get this to run. I think it might be to do with my triggers for when to run, which I set to run if the REQ Requested for is empty. I also tried to set it for everytime a certain item is created but this is not working either.

Below is the script and the trigger.

find_real_file.png

 

var grREQ = new GlideRecord('sc_request');
    grREQ.get(current.sc_request);
    grREQ.requested_for = current.requested_for;
    grREQ.update();

1 ACCEPTED SOLUTION

Hi,

Can you please try below:

var grREQ = new GlideRecord('sc_request');
	grREQ.get(current.request.toString());
	grREQ.requested_for = current.requested_for.toString();
	grREQ.setWorkflow(false);
	grREQ.update();
	
	current.work_notes = 'test';
	current.setWorkflow(false);
	current.update();

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

13 REPLIES 13

Hi,

OOB there is no requested_for field on RITM table

Can you check in form layout if that field is the dot walked field from REQ

Regards
Ankur

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

Hi Ankur,

Since Paris version Requested for field is available on 'sc_req_item' table.

find_real_file.png 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Oh okay.

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

Chetan Mahajan
Kilo Sage

Hi,

      if you have requested for field on catalog item itself, write BR on RITM

 var requestUser = current.variables.requested_for;
    var gr = new GlideRecord('sc_request');
    gr.addQuery('sys_id', current.request);
    gr.query();
    if (gr.next()) {
        gr.setValue('requested_for', requestUser);
        gr.update();
    }

 

Kindly mark correct/helpful if it's useful to you