Adding script to add records in table

Ajinkya Avinash
Giga Contributor

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

5 REPLIES 5

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