How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 10:23 PM
How to update Read only Custom field to Null for 100 of records in alm_hardware Table using Fix script or any other Method?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 10:41 PM
Hi @VIKAS45
Step 1: Navigate to Background Script Scripts - Background
Script:
var tableName = 'alm_hardware';
var customFieldName = 'u_custom_field'; // REPLACE with your field name
var gr = new GlideRecord(tableName);
gr.query(); // Execute the query to retrieve the records
var count = 0;
while (gr.next()) {
gr.setValue(customFieldName, ''); // Set the field value to null (empty string in this context)
gr.setWorkflow(false); // Optionally, skip business rules, if necessary
gr.update(); // Update the record
count++;
}
gs.info(count + ' records updated in ' + tableName);
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 11:02 PM
Hi @VIKAS45
You can use either fix scripts or background scripts or you can even schedule it
below is the sample code
var almAsset= new GlideRecord("alm_hardware");
almAsset.query();
while (almAsset.next())
{
almAsset.customFieldName= " ";
almAsset.update();
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 11:05 PM
Hi @VIKAS45 ,
Can use a background script or fix script.
please find the script below,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 11:24 PM
Hi @VIKAS45 ,
You can use background script or fix script.
var gr_hardware = new GlideRecord("alm_hardware");
gr_hardware.addEncodedQuery(""); // Add your encoded query here which filters your required records
gr_hardware.query();
while (gr_hardware.next())
{
gr_hardware.autoSysFields(false); // this will prevent updating updated by and updated field, use if required.
gr_hardware.setWorkflow(false); // skip business rules
gr_hardware.setValue(customFieldName, ''); // Set the field value to null
gr_hardware.update();
}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me.
Thank you!
Abhishek Dalvi