Programatically create demo data with fixed Number values from scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 04:19 PM - edited 11-07-2023 05:27 PM
My requirement is to create a set of demo data (like incidents) for my scoped app as though the records were created X number of days ago. Therefore, I am programmatically setting sys_id, Number, and dates.
I am able to set sys_id and dates, but not set the Number value unless I turn off workflows/BRs, which is only working from Global scope, not from my app scope. I'd prefer to let workflows/BRs run anyway, so my issue is not that setWorkflow fails in scope, but that I can't set the Number from within scope. Any thoughts?
Code sample:
var gr = new GlideRecord('incident');
gr.initialize();
gr.setNewGuidValue('12345678901234567890123456789012'); // WORKS
gr.autoSysFields(false); // WORKS
gr.setValue('sys_updated_on', '2020-01-01 00:00:00'); // WORKS
gr.setWorkflow(false); // ERROR IN APP SCOPE
gr.number = 'INC0011196'; // IGNORED
gr.caller_id = gs.getUserID(); // WORKS
gr.insert(); // WORKS, BUT WITH AUTO-GENERATED NUMBER 😩
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:58 AM
please see the script that was added
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 10:51 AM
I suggest you work with your colleagues on the PT support team. You can change the number field after records are created. See:
good luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 12:10 PM - edited 11-16-2023 12:10 PM
You can also change the value in the sys_number_counter table for table "incident" to start auto-numbering at that value.