- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 12:43 AM
how to update the stockroom name based on the assignment group ?
i tried to use this but stockroom field of the form is still blank
i created the business rule on it .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 05:15 AM - edited 02-02-2024 05:22 AM
Hi @chercm,
Got it. I've spotted a few minor issues based on what you're trying to achieve.
I've tested this on a PDI and can confirm it works as required.
Update the following:
Business Rule. When to run: 'before'
Business Rule Script: (Ready for you to copy and paste)
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 05:55 AM
Hi @chercm ,
The reason you need to pass the sys_id when setting the stockroom is because the field is of type reference, meaning that it is actually pointing to another table. In order to set this value, you need to use the sys_id.
You will however see the name displayed on the form.
Have you seen my latest post? I've checked the script on a PDI and it works as required. Please can you copy and paste my script.
Please also ensure you have the Business Rule to operate 'on before' and check the 'Update' checkbox.
Out of interest, when do you set the assignment group? Do you have an Assignment Rule in operation? Have you implemented the script and changed the Assignment group value manually on the form to ensure the script is at least running?
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 01:00 AM
Hi @chercm adjusted the code below
if (current.assignment_group !='') {
// Query the Stockroom based on Assignment Group
var stockroomGR = new GlideRecord('alm_stockroom');
stockroomGR.addQuery('assignment_group', current.assignment_group);// your checking grp name here not sys_id so change it to grp
stockroomGR.query();
// If a stockroom is found, set the Stockroom field on the catalog form
if (stockroomGR.next()) {
current.stockroom = stockroomGR.getValue('name');
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 04:23 AM
@Harish KM @Robbie i tried to change to assignment_group but still does not work
here is the updated script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 04:36 AM
Hi @chercm is this BR after update? if yes please add current.update()
// Query the Stockroom based on Assignment Group
var stockroomGR = new GlideRecord('alm_stockroom');
stockroomGR.addQuery('assignment_group', current.assignment_group);// your checking grp name here not sys_id so change it to grp
stockroomGR.query();
// If a stockroom is found, set the Stockroom field on the catalog form
if (stockroomGR.next()) {
current.stockroom = stockroomGR.getValue('name');
current.update(); // need update
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 04:41 AM
@Harish KM does not work with the update code