Adding script to add records in table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 09:43 AM
Hi I have one Major table Reports I have 4 Related list for the same table, whenever any record gets inserted in Reports table i want to add respective number of records in related list tables as well
I have written below script
for(var i = 1;i<5;i++){
var gr = new GlideRecord('u_a1');
gr.initialize(); //this will create an empty record to populate before an insert.
gr.u_number_a1 = current.sys_id;// this will give the reference for the record
gr.setValue('u_sr', i);
gr.setValue('u_proffetional_category', i);
gr.insert();
}
for(var j = 1;j<5;j++){
var gr1 = new GlideRecord('u_a2');
gr1.initialize(); //this will create an empty record to populate before an insert.
gr1.u_number_a2 = current.sys_id;// this will give the reference for the record
gr1.setValue('u_sr', j);
gr.setValue('u_professional_category_a2', j);
gr1.insert();
}
I have kept u_professional_category choice list values are 1 2 3 and 4 as i want but its getting converted into float i am not getting why it is converted into a Float value.
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 09:46 AM
What type of fields are your u_proffetional_category and u_professional_category_a2
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 12:19 AM
Choice field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 01:07 AM
Hi Ajinkya,
Can you share the dictionary entry for those 2 fields and also their choice values?
can you set it as below?
gr.u_proffetional_category = i;
gr.u_professional_category_a2 = j;
Regards
Anku
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:09 AM