- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 02:16 AM
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.
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.
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.sc_request);
grREQ.requested_for = current.requested_for;
grREQ.update();
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 07:14 PM
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 03:52 AM
Thanks Anil, This started copying over the user info, I will admit there was a duplicate key error I started receiving once I added all of the code above. However, I am actually going a different route and no longer need this.
I have marked correct in case anyone else might need the answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 02:23 AM
Hi,
requested_for is field on REQ
So it should be filled with which user?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 03:25 AM
This would be the person on the requested_for field on the RITM table, which fills out so not sure why it does not also apply to the REQ requested_for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 03:37 AM
Hi,
RITM table doesn't have OOB requested_for field
Are you saying the RITM table's custom field u_requested_by value should be set in REQ -> requested_for?
if yes then update as this
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.request.toString());
grREQ.requested_for = current.u_requested_by ;
grREQ.update();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 08:53 AM
I thought there was an OOB field for requested for on the RITM table? I have one that does get populated and that is what I am trying to copy to go into the Request requested for.
The field name is requested_for and this is on the sc_req_item table.
I have tried the following script but it is not copying over the information.
var grREQ = new GlideRecord('sc_request');
grREQ.get(current.request.toString());
grREQ.requested_for = current.requested_for;
grREQ.update();
current.work_notes = 'test';
current.update();