Amit Gujarathi
Giga Sage

HI @Ra_l Ruvalcaba ,
I trust you are doing fine.
To identify all the changes in the "state" field of the "cmdb_ci_server" table and obtain the count of records that have been updated, you can use a GlideRecord query in ServiceNow.

// Create a new GlideRecord instance for the cmdb_ci_server table
var gr = new GlideRecord('cmdb_ci_server');

// Add a query condition for the desired state values
gr.addQuery('state', 'IN', ['value1', 'value2', 'value3']); // Replace 'value1', 'value2', 'value3' with your desired state values

// Add an additional query condition for the desired date range, if needed
gr.addQuery('sys_updated_on', '>=', 'yyyy-MM-dd 00:00:00'); // Replace 'yyyy-MM-dd' with your desired start date

// Add another query condition for the desired date range, if needed
gr.addQuery('sys_updated_on', '<=', 'yyyy-MM-dd 23:59:59'); // Replace 'yyyy-MM-dd' with your desired end date

// Execute the query
gr.query();

// Get the count of records that match the query
var recordCount = gr.getRowCount();

// Print the count of updated records
gs.info('Number of records updated: ' + recordCount);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi