- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 02:42 AM
Hello Everyone,
I have a "Install location" reference filed on my catalog item form.So i have to Update “Location” field in the Hardware table based off the asset that appears in the RITM under Asset tab. The location should be pulled from the “Install Location” field on the form.
So A script would run to update location based off what is on the UI Install Location.I should add run script in the workflow so can some one help me with the script.It would be very thankful.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 09:07 AM
Hello,
Thanks for the replies i have done this by using script include and called in workflow run script now the issue is resolved thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 03:19 AM
Hi Mercy,
Check the below links for reference,
If my reply has helped you,Kindly click the Helpful button.
If my reply is the answer you were looking for, Kindly click the Accepted Solution button.
Thanks,
Priya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 10:11 PM
Try the following script:
var asset = new GlideRecord('alm_asset');
asset.addQuery('request_line',current.sys_id);
asset.query();
while(asset.next()){
var eachAsset = new GlideRecord(asset.sys_class_name);
eachAsset.get('asset_tag',asset.asset_tag);
if(eachAsset.isValidRecord()){
eachAsset.location = current.variables.<your location variable>; //replace <your location variable> with the name of your location variable
eachAsset.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 07:03 AM
Hi Moy,
Thanks for the reply but somehow its not working as expected still location in asset harware table is not getting updated with the Install location which is on the Catalog item UI.
Whenever i selects Install location on the UI and submits the Request In RITM below I can see the Asset tab that is beside the task approval,Approvals so there i'm selecting the Asset->new i'm selecting new asset tag and submitting.whenever i open the particular assettag in the harwaretable "alm_asst" there is a location filed consist on the form so that location needs to be updated with the Install location which ever selected on Catalog Ui .
It should be happen from the workflow for that RUN script should run.
I have tried the script which you have provided that is returing with no error but at the same time unable to get the result as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 10:59 PM
The result that you are seeking will not fruition. The script that I have provided will work on a run script activity of a workflow when there are existing assets that are related to that RITM (request line). The workflow will not execute if you add a new asset my clicking the 'new' button on the 'Asset' related tab.
For your requirement, you will need to execute a business rule that executes on all the cases that can be related to the request line. Providing you an example below:
table: cmdb_ci
condition: after / insert
condition script: current.sys_class_name =='alm_asset' && sys_class_name ==<insert the class name>
script:
var RITM = new GlideRecord('sc_req_item');
RITM.get(current.request_line);
if(RITM.isValidRecord()){
current.location = RITM.<name of the variable that contains the location>;
}