- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 02:40 AM
i am trying to set one value is empty and i tried below script but still not working please check and help me anyone with my mistake
var test1 = new GlideRecord('alm_hardware');
test1.get('u_premium_service.u_number='+ritm.variables.hardware_asset^asset_tag!=ritm.variables.hardware_asset^ORasset_tag=NULL');
//remove PREMxxxx01 from hardware asset table
test1.u_premium_service = "";
test1.update();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 02:44 AM - edited 11-03-2023 02:45 AM
Hi,
Try this
var test1 = new GlideRecord('alm_hardware');
test1.addEncodedQuery('u_premium_service.u_number='+ritm.variables.hardware_asset+'^asset_tag!='+ritm.variables.hardware_asset+'^ORasset_tag=NULL');
test1.query();
while(test1.next()) //use if if you are expecting only 1 record to be returned
//remove PREMxxxx01 from hardware asset table
test1.u_premium_service = "";
test1.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 02:44 AM - edited 11-03-2023 02:45 AM
Hi,
Try this
var test1 = new GlideRecord('alm_hardware');
test1.addEncodedQuery('u_premium_service.u_number='+ritm.variables.hardware_asset+'^asset_tag!='+ritm.variables.hardware_asset+'^ORasset_tag=NULL');
test1.query();
while(test1.next()) //use if if you are expecting only 1 record to be returned
//remove PREMxxxx01 from hardware asset table
test1.u_premium_service = "";
test1.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 02:45 AM
your query is wrong.
form the correct query with correct fields and the operators i.e. AND, OR
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 02:56 AM
what is stored in that variable hardware_asset?
you are comparing it against asset_tag field and also against u_premium_service.u_number
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader