- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2018 08:37 AM
Hello,
I'm working on a catalog item request and needed help with the following requirement:
- Update Stockroom field to 'Tower Loaner' based on current value of Computer variable.
- The logic is that if the computer is in stock, then it gets returned to the stockroom named 'Tower Loaner'.
- Note: The Computer variable on my request is a reference field associated to the [cmdb_ci_computer] table.
All the other fields in my workflow run script are updating as required with the exception of the Stockroom field (gr.asset.stockroom). The Stockroom field is associated to the [alm_asset] table, so I tried dot-walking but had no luck on making this work. Any feedback would be much appreciated.
runScript();
function runScript() {
var gr = new GlideRecord('cmdb_ci_computer');
if (gr.get(current.variables.computer)) {
gr.hardware_status = 'in_stock';
gr.hardware_substatus = 'available';
gr.assigned_to = '';
gr.asset.stockroom = '43bcbca81340df00cd9f74c66144b0f2'; //Tower Loaner Stockroom
gr.update();
}
}
CI Record:
Stockroom Record:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2018 08:41 AM
You can't update a field in a reference record from source record. Use below code.
runScript();
function runScript() {
var gr = new GlideRecord('cmdb_ci_computer');
if (gr.get(current.variables.computer)) {
gr.hardware_status = 'in_stock';
gr.hardware_substatus = 'available';
gr.assigned_to = '';
//gr.asset.stockroom = '43bcbca81340df00cd9f74c66144b0f2'; //Tower Loaner Stockroom
gr.update();
}
var gr1 = new GlideRecord('alm_asset');
gr1.addQuery('ci',current.variables.computer);
gr1.query();
if (gr1.next()){
gr1.stockroom = '43bcbca81340df00cd9f74c66144b0f2'; //Tower Loaner Stockroom
gr1.update();
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2018 08:41 AM
You can't update a field in a reference record from source record. Use below code.
runScript();
function runScript() {
var gr = new GlideRecord('cmdb_ci_computer');
if (gr.get(current.variables.computer)) {
gr.hardware_status = 'in_stock';
gr.hardware_substatus = 'available';
gr.assigned_to = '';
//gr.asset.stockroom = '43bcbca81340df00cd9f74c66144b0f2'; //Tower Loaner Stockroom
gr.update();
}
var gr1 = new GlideRecord('alm_asset');
gr1.addQuery('ci',current.variables.computer);
gr1.query();
if (gr1.next()){
gr1.stockroom = '43bcbca81340df00cd9f74c66144b0f2'; //Tower Loaner Stockroom
gr1.update();
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2018 08:55 AM
The script worked perfectly. Thank you so much sanjivmeher. I appreciate your help and the prompt response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2018 08:43 AM
You'll need to lookup the asset records separately to update it.