Populate "Requested for" and "Opened for" on REQUEST and RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2018 10:40 PM
Hi,
Pretty basic and straightforward question - how do we populate "Requested for" field on REQUEST and "Opened for" field on REQUESTED ITEM (RITM) when a catalog item is submitted by and end user. I've seen business rule approaches but this shouldn't be that complex. I mean, it should be straightforward to push these details from an end user form to requested item (without any scripting)?
We have to do this across all items in the catalog. Any insight will be helpful.
Thanks.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2018 10:57 PM
Hello there,
write a catalog client script something like this:
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next()){
req.requested_for = current.variables.user; //current.variables.user is to read the user name from catalog form. same like opend, you can pick other variable value.
req.update();
}
sreedhar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2018 11:03 PM
Hello,
Have a variable set with variable as requested_for (basically for maintaining same variable name in all items) and include the variable set in all items (currently if variable name for requested for is same in all items then no need of this).
Have business rule in requested item table as.
//to update RITM
current.opened_for = current.variables.requested_for;//update variable name as in your item
..To update request
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next()){
req.requested_for = current.variables.requested_for;//update variable name as in your item
req.update();
}
Thanks,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2018 11:26 PM
Hi,
This can be done pretty simply using the Workflow created on the sc_req_Item table by creating a 'Run Script' Activity. In the Activity use the below code :-
var request = current.request.getRefRecord();
request.opened_by = current.variables.opened_by.toString();
request.requested_for = current.variables.requested_for.toString();
request.update();
current.opened_by = current.variables.opened_by.toString();
Hope this helps.
Mark the answer as correct/helpful if you are satisfied.
Thanks,
Angshuman