- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2021 04:01 PM
Hi All,
I'm working on a catalog item that includes 2 variables: Computer (references [cmdb_ci_computer] table) & Stockroom (references [alm_stockroom] table). The requirement is to automatically populate the Stockroom variable based on the CI selected in the Computer variable. This requires 2 levels of dot-walking from the CI.Asset.Stockroom and I believe the best approach is to create a Script Includes + Catalog Client Script. I created both scripts below, however the functionality isn't working. Any guidance on what's missing would be much appreciated.
Computer CI Record:
Hardware Asset Record:
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 02:08 PM
Couple things:
1. this should solve your issue - change "return gr.asset.stockroom.getDisplayValue();" to "return gr.asset.stockroom.toString();". You need a sys_id as your variable is a reference field, correct?
2. Just to make things easier, change "ga.getXML(callBackMethod);" in the Client Script to "ga.getXMLAnswer(callBackMethod);". That way your "response" parameter contains the result without having to pick the answer out of the XML tree.
Just try #1 first to confirm and #2 if you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2021 04:09 PM
hi
var grAsset = current.asset.getRefRecord();
if(grAsset.isValidRecord()) { // << only perform operations on it if it's a valid record
return grAsset.getDisplayValue("stockroom");
}
return "";
please replace my code for line "return gr.asset.stockroom.getDisplayValue();"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2021 09:18 PM
Hi - Thanks for the response. Unfortunately that script didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2021 04:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 07:09 AM
Any input from the community would be appreciated.