How get next number while insert()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 02:32 PM
Var inc = new GlideRecord('u_state_filing');
Var inc1= new GlideRecord('sys_choice');
Inc1.addEncodedQuery('u_state_filing^element=u_provinces');
Inc1.query();
while(Inc1.next()){
inc.u_parent_number= current_sys.id;
Var SysID = inc.insert();
Var MySysID= current.update();}
Basically I have a choice field and want to create same number of records, as choice numbers.also want to set the choice for each record as per selection.
Tried with for Loop but did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 06:53 AM
Thanks Chuck for the response, as per the above image highlighted Value field need to be filled in u_provinces for new record. But It does not set the value for each record that is created.
For eg; for 1st record set u_provinces= AB
2nd record set u_provinces=BA
and so on
till last record set u_provinces= GL
I tried this another way, through List type field;
As this comma separated, I created a choice (ALL) with it;s value(AB,BA,CD). It did create 3 records but u_provinces got new choices as AB\...next BA\.. next CD
If I select all the choices, and then select UI action it does create records as required. However, If I again select it does create same set of records.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 06:57 AM
Using the choice list field the way you had should work. Just add your field assignment where I had the comment.
var choice = new GlideRecord('sys_choice');
choice.addEncodedQuery('u_state_filing^element=u_provinces^language=en^inactive=false');
choice.query();
while(choice.next()){
var inc = new GlideRecord('u_state_filing');
inc.newRecord();
inc.u_parent_number = current.sys_id;
// add other inc field values here
inc.u_provinces = choice.getValue('value');
inc.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 08:18 AM
Thanks Chuck for this. I am trying to copy the record while I have same parent number