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
04-05-2020 06:27 AM
Hi,
I am going to advise one thing just for testing and see if that works:
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', parseInt(i));
gr.insert();
}
Thanks,
Ashutosh