
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 06:17 AM
Excuse my ignorance here, but this is not my area of expertise.
Need to remove a hardcoded prefix value in the field alm_hardware.asset_tag from "ABC-" to null
Here's my code, but it's not working and need help
var gr = new GlideRecord('alm_hardware');
gr.addQuery('asset_tag' , 'STARTSWITH' , 'ABC-');
gr.setLimit(1);
gr.query();
while (gr.next()) {
gr.setvalue('asset_tag',gr.getvalue('asset_tag').replace('ABC-',''));
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 06:20 AM
Hi @David77
Try following script once:
var gr = new GlideRecord('alm_hardware');
gr.addQuery('asset_tag', 'STARTSWITH', 'ABC-');
gr.query();
while (gr.next()) {
var updatedAssetTag = gr.getValue('asset_tag').replace('ABC-', '');
gr.setValue('asset_tag', updatedAssetTag);
gr.update();
}
I hope my answer helps you to resolve your issue, if yes mark my answer helpful and correct.
THANK YOU
rajesh chopade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 06:27 AM - edited 08-07-2024 06:31 AM
@David77 Your almost there. Try assigning gr.getvalue('asset_tag').replace('ABC-','') to a variable and pass that variable in your set value.
please mark my response is helpful and accept the solution if it help you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 08:04 AM
@Satishkumar B thanks! only thing i still had to do was code it as: getValue
Did not realize case mattered in these commands. Thanks!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 06:20 AM
Hi @David77
Try following script once:
var gr = new GlideRecord('alm_hardware');
gr.addQuery('asset_tag', 'STARTSWITH', 'ABC-');
gr.query();
while (gr.next()) {
var updatedAssetTag = gr.getValue('asset_tag').replace('ABC-', '');
gr.setValue('asset_tag', updatedAssetTag);
gr.update();
}
I hope my answer helps you to resolve your issue, if yes mark my answer helpful and correct.
THANK YOU
rajesh chopade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 06:27 AM - edited 08-07-2024 06:31 AM
@David77 Your almost there. Try assigning gr.getvalue('asset_tag').replace('ABC-','') to a variable and pass that variable in your set value.
please mark my response is helpful and accept the solution if it help you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 08:04 AM
@Satishkumar B thanks! only thing i still had to do was code it as: getValue
Did not realize case mattered in these commands. Thanks!!!