- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 03:10 AM - edited 11-20-2024 03:12 AM
Hi all,
I have a requirement to show Requested Items as a Related List on our Environment form, based on the name of the Environment selected against the Catalog Item that forms the Request.
For example, if the Cat Item Variable selected on the Requested Item is 'Server A' and matches the name value on the respective Environment form, I want these Requests to populate against the Related List.
Cat Item = 'Enable Environments (On Demand)'
Cat Item Variable = 'Please select the Environment to enable.' (Reference field)
Could someone help me formulate the script within the Relationship to automatically bring back these RITM's please?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 04:09 AM - edited 11-20-2024 04:20 AM
A script like this will show RITMs with a reference variable value that equals the displayed record:
(function refineQuery(current, parent) {
current.addEncodedQuery('variables.your_variable_sys_id='+parent.sys_id);
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 04:08 AM - edited 11-20-2024 04:37 AM
Hi @GMoon,
You can create a Relationship record with following configuration:
Applies to Table: Environment [cmdb_ci_environment]
Queries from Table: Requested Item [sc_req_item]
Script:
(function refineQuery(current, parent) {
//Replace YOUR_VARIABLE_SYS_ID with the sys_id of the reference variable that holds the Environment value in your catalog
current.addEncodedQuery('variables.YOUR_VARIABLE_SYS_ID='+parent.sys_id);
})(current, parent);
Hope it helps 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 04:09 AM - edited 11-20-2024 04:20 AM
A script like this will show RITMs with a reference variable value that equals the displayed record:
(function refineQuery(current, parent) {
current.addEncodedQuery('variables.your_variable_sys_id='+parent.sys_id);
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 05:26 AM
Thanks once again Brad, appreciate your time.