Requested for on RITM is not updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 03:24 AM
Hi,
I have a requirement to update the 'Requested for' (on both REQ and RITM) filed based on what is entered in the 'contact' field in the catalog item during the request submission.
For example: ABC is a catalog item and there is a field called 'contact' in the item which is a reference to the 'user' table. During the request submission if I choose 'Abel' in contact field and submit the request, the 'requested for' of the REQ and RITM should be updated to 'Abel' not the logged in user.
For this I have written the script in the workflow.
Below is the script:
var reqRecord = current.request.getRefRecord();
reqRecord.requested_for = current.variables.request_for;
reqRecord.update();
This was working earlier but not sure why it isn't working now. No matter what I select in the 'contact' field the 'requested for' of the REQ and RITM is set to the logged in user.
Could this be because of the 'San Diego' version or the patch upgrades?
Is there any way I can achieve this may be using a business rule?
Requesting the suggestions, Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 03:50 AM
Try to make below changes in your script:
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next())
{
req.requested_for = current.variables.requested_for;
req.update();
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:01 AM
Hi @RaghavSh , Thanks for your reply. I tried the above code, but it didn't work. It's still taking the logged in user as the requested for.
Is there a way that I can try the same in business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 06:42 AM
Use below code in BR (after update) on RITM table:
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next())
{
req.requested_for = current.variables.requested_for;
req.update();
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 08:29 AM
@Blessy2 did this work for you?
Raghav
MVP 2023