Capturing data of a variable set in a record producer

Mohammad8
Kilo Expert

Hi All,

I have a record producer that contains some fields. Every field maps to a corresponding field in my table. I also have a multi-row variable set but it cannot be mapped to a particular field in my table. The normal fields go straight to my table when the record producer form is submitted, the only problem I have is with the variable set. I don't know how to capture it data. Any help is this?

 

Thanks in advance

1 ACCEPTED SOLUTION

Okay, fine.

Go to your record producer as admin.

Under "What it will contain", you will see  a script field.

This will be executed after the record producer is submitted.

So here you can access the variable set data using like below

var variable1 = gr.variables.table_var.var1; //table_var is multi row set name and var1 is the variable name inside the variable set.

Once you access this value, where do you want to store this data? In which table and fields you want to store it?

if you want to store in custom table, then use code like below

var cust = new GlideRecord("your_table");

cust.initialize();

cust.field_name = variable1;

cust.insert();

Also, i suggest you to check out the OOB record producers where multi row variable set is used and see how they are being used.

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

6 REPLIES 6

Okay, fine.

Go to your record producer as admin.

Under "What it will contain", you will see  a script field.

This will be executed after the record producer is submitted.

So here you can access the variable set data using like below

var variable1 = gr.variables.table_var.var1; //table_var is multi row set name and var1 is the variable name inside the variable set.

Once you access this value, where do you want to store this data? In which table and fields you want to store it?

if you want to store in custom table, then use code like below

var cust = new GlideRecord("your_table");

cust.initialize();

cust.field_name = variable1;

cust.insert();

Also, i suggest you to check out the OOB record producers where multi row variable set is used and see how they are being used.

Mark the comment as a correct answer and also helpful once worked.

Hi Asif,

I am using the below script in my record producer and it doesn't work. Could you please suggest if there is a script error? Any help is appreciated.

var var1 = gr.variables.product_information.product_name; //table_var is multi row set name and var1 is the variable name inside the variable set.
gs.log('Product var: ' + var1);
var var2 = gr.variables.product_information.description;

var count = gr.variables.product_information.getRowCount();
gs.log('Product Count: ' + count);

var pi = new GlideRecord("u_product_information");
pi.initialize();
for(var i = 0; i<count.length;i++){

pi.u_product_name = var1;
pi.u_description = var2;
pi.insert();
}

 

Best,

Jag.