Glide Records : My insert script inserts multiple(100+) records in table

IAmIshan
Tera Guru

Instead of single record below script is adding multiple records in table.

 

var s=new GlideRecord('u_empdata');
s.initialize();
s.setValue('u_first_name','John');
s.insert()

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

How are you executing this script ? 

Did you try to run on background script to test, i can see it will create only one record . 

tested at my end on background script:

 

var s=new GlideRecord('sys_user');
s.initialize();
s.setValue('user_name','John');
s.setWorkflow(false);
s.insert();

 

Make sure you don't have any other script contradicting here. 

 

 

View solution in original post

4 REPLIES 4

Harsh Vardhan
Giga Patron

How are you executing this script ? 

Did you try to run on background script to test, i can see it will create only one record . 

tested at my end on background script:

 

var s=new GlideRecord('sys_user');
s.initialize();
s.setValue('user_name','John');
s.setWorkflow(false);
s.insert();

 

Make sure you don't have any other script contradicting here. 

 

 

Hi Harshvardhan  

                  I tried mentioned script using Business Rules, Also I did this using Background Script also and creates only one record.

                How this can be possible?

Can you add more details, in what scenario its creating multiple record. 

as you have mentioned , while using it on background script it's creating one record. so I am assuming while using it on business rule, it's creating multiple record? if yes, have you checked any other existing server side script or business rule contradicting here ? 

The script which you have shared is absolutely correct and it should create one record. You must have some existing script contradicting here , so I would suggest , please provide more details about your testing scenario.  

Now my problem is Solved.....I just missed setWorkflow method.

Can you please tell more about setWorkflow. And how this helps me to solved my problem.