Populate value of sc_req_item item from Catalog variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 11:44 AM
Is there a script where I can take the value that user enters in Requested Item variable and populate that value in a sc_req_item field
Thanks
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 12:03 PM
Ganest - yes, you are correct. Customer has an option to select which 'assignment group' they want the item to be assigned to. Then I would like whichever assignment group is selected to populate the 'assignment_group' field in sc_req_item. Hope that makes sense.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 12:10 PM
Hi Edwin,
You DONT want to go for a Business rule as it be rule on a generic table for a specific item.
Use Run script activity in WF or a flow designer.
you will have access to your variables through current.variables.XXX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 12:10 PM
Then write below script using BR on RITM table (after Insert)
var ritm = new GlideRecord(sc_req_item);
ritm.addQuery('sys_id',current.sys_id);
ritm.query();
if(ritm.next()){
var xyz = ritm.variables.<Variable database value>.
gs.log(xyz);// since assignment group is a reference field, make sure variable xyz returing sys_id.
current.assignment_group = xyz;
ritm.update();
}
If you are using workflow then best way is to Use a workflow activity called 'Run Script'. If you are not using workflow then go for first suggestion.
here is the simple line for to meet your requirement
current.assignment_group = current.variables.<variable value>;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 12:05 PM
Another way you can do this is through a Run Scripts workflow activity in your workflow. I typically will set the short description of the Requested Item using this method. For example, let us say we have a request that allows us to add or remove a user from a group. This form has a variable called: Add or Remove [add_remove_choice] and that variable has two choices Add, Remove. Here is the Run Scripts script that you would use:
var sDesc = 'Group Membership - ' + current.variables.add_remove_choice.getDisplayValue();
current.short_description = sDesc;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 12:40 PM
Thanks everyone for your suggestions. Seems like the general consensus is to write a workflow script to populate said field. I will work on that and update you all. Appreciate it.