Generate multiple records based on list collector variable

Thrupthi
Tera Expert

Can someone please assit on this.

I have table newly created called "x_pgpl2_visitor_re_visitor_registration", i have created the new record producer and have used one variable as "list collector"

I have created the workflow and have added the run script to create records based on the value of list collector.

Result:

Example if i fill in variable (list collector) as "ABC", "BCD", "DDD"

It creates 4 records

1. one record containing all the other varibales

2. record two containing "list collector value " ABC on record and rest of the variables remains blank

3.record three containing "list collector value " BCDon record and rest of the variables remains blank

4.record four containing "list collector value " DDD on record and rest of the variables remains blank

 

Script used: 

 

var listStr = current.variables.Visitor_Name.toString(); //Visitor_Name list collector variable
var list = listStr.split(',');
for (var i = 0; i < list.length; i++) {
var record = new GlideRecord('x_pgpl2_visitor_re_visitor_registration');
record.initialize();
record .request = current.request;
record .visitor_name = list[i]; //name of the table field
record .insert();
}

 

18 REPLIES 18

Sateesh Kumar 2
Kilo Guru
Hello, The script looks perfect except the space after record in last 3 lines , not sure whether that could cause this issue. If that doesn’t sole see if there are any business rule on the table. Regards, Sateesh kumar Devadoss

Its newly created table, there are no BR's on this table.

Harsh Vardhan
Giga Patron

assuming you have selected the same table on record producer if yes then of course it will create 4 record because your record producer has been set on same table which you are doing glide-record . 

 

 

yes I have selected the same table. It should create 3 record based on list collector values right, why 4 here!

My main concern is it doesnt capture rest of variables on either of the records except 1.