How to store record producer Muti row variables set in custom table

Harish6
Giga Contributor

Hi Team,

I am using multi row variable set in record producer, we are able to insert the data from Catalog item but we are not able see that data once record generated in the portal.

Please help me to understand how to store record producer multi row variable set in custom table.

Appreciate your response.

find_real_file.png

Thanks & Regards

Harish

7 REPLIES 7

Harsh Vardhan
Giga Patron

you custom table is different from the table which you selected on your record producer  ? 

adding sample code:

 

var mrvs = JSON.parse(producer.<multi row variable set internal name>);

var rowCount = mrvs.length;

for (var i = 0; i < rowCount; i++) {
var gr = new GlideRecord('Custom Table');
gr.initialize();
gr.setValue('u_account', row.<multi row column>);
gr.insert();
}

 

Note: you will use it on your record producer script field. 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harish,

You can either create records in custom table once target record is created or you can use record producer script

please refer sample script below which you can use in record producer script

Note: Ensure you use proper

1) MRVS variable name

2) Table columns

3) Table name

4) MRVS individual variable names such as ticket number, ticket description etc

var variableValue = producer.<MRVSvariableName>;

var parser = JSON.parse(variableValue);

var gr = new GlideRecord('table_name');

for(var i=0;i<parser.length;i++){

gr.initialize();

gr.field1 = parser[i].ticket_number;

gr.field2 = parser[i].ticket_description;

gr.field3 = parser[i].ticket_working_time;

gr.field4 = parser[i].ticket_number;

gr.insert();

}

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thank you for response..

regarding table columns do i need to create a columns in custom table which i used in record producer.

if yes, which type of variable i need to create in table.  

 

Thanks & Regards

Harish

Hi Harish,

Yes that was my assumption. You need to have columns in custom table to store the data if you wish each variable should be mapped to individual columns.

Ensure the variable type from MRVS matches the field type in custom table

Example:

If variable type of Ticket Number in MRVS is of type reference to change_request then field should also be reference type referring to change_request table

In this manner no need to extra efforts while parsing the MRVS value

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader