var gr = new GlideRecord("cmdb_ci_computer"); gr.orderBy('sys_created_on'); gr.query(); while (gr.next()) { var nm = new NumberManager('cmdb_ci_computer'); gr.u_number = nm.getNextObjNumberPadded(); gr.autoSysFields(false); // Do not update sys_updated_on, sys_updated_by, and sys_mod_count gr.setWorkflow(false); // Do not run any other business rules gr.update(); }
Auto Numbering for Existing Records ServiceNow
Working Code Asked question December 4, 2023