- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 09:18 AM
Just looking for sample code to update a field value on all contact records.
Table: customer_contact
Field: Verification Status (u_verification_status)
Value: Not Verified
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 09:29 AM
Hi @MStritt,
To update the "Verification Status" field on all contact records in the "customer_contact" table in ServiceNow, you can use the following sample code:
var gr = new GlideRecord('customer_contact');
gr.query();
// Loop through each record and update the field
while (gr.next()) {
gr.setValue('u_verification_status', 'Not Verified');
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 09:33 AM
Hi @MStritt ,
// Define the new value for the Verification Status field
var newValue = 'Not Verified';
// Create a new GlideRecord for the customer_contact table
var contactGr = new GlideRecord('customer_contact');
// Add a query to target all records (optional if you want to filter specific records)
// contactGr.addQuery('your_condition_field', 'your_condition_value'); // Uncomment and customize as needed
contactGr.query();
// Loop through the records and update the Verification Status field
while (contactGr.next()) {
contactGr.u_verification_status = newValue;
contactGr.update();
}
gs.info('Verification Status updated on all contact recordsto: ' + newValue);
Thanks,
Danish