- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:00 AM
Hello Experts,
I have created auto numbering for existing software model table. The issue is we have few old records for which we need numbering as well but it works only for newly created records. Is there a way to generate numbering for existing records as well. Thank you in advance.
Thanks & Regards,
Jag.
Solved! Go to Solution.
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 11:49 AM
Sorry change line 6 to gr.u_number so...
var gr = new GlideRecord("cmdb_software_product_model");
gr.orderBy('sys_created_on');
gr.query();
while (gr.next()) {
var nm = new NumberManager('cmdb_software_product_model');
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:11 AM
Hi,
You need to generate the number for old records in sequence using a background script and then update the latest counter in your number table for new records.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:17 AM
Hello Alikutty,
Thank you for your response. Could you please provide me some reference background script if you have any.
Thanks & Regards,
Jag.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:22 AM
var gr = new GlideRecord('cmdb_software_product_model'); //This should be your table.
gr.query();
var prefix = "SW"; //Change to your numbering prefix
var counter = "0000000"; //Should be set to number of 0's in your number
while(gr.next()){
counter += 1;
gr.number = prefix+counter; //number should be your field name for number column
}
Please try and let me know, Once number is populated, you should update your counter in numbering table to the latest counter.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:41 AM
Hello Alikutty,
After running the background script, the number is not getting populated. It still showing empty.
Thanks & Regards,
Jag.