create MRVS records with some array data

Community Alums
Not applicable

i have data with array as below

[{ "meterialID:"1220000", "DescriptionID": "tandard qa", "Quantity": 1 },{ "meterialID:"1220000", "DescriptionID": "tandard qa", "Quantity": 1 }]

 

i want add records in catalog MRVS variable set while submitting catalog through script or flow designer.

 

Please share any ideas....

 

3 REPLIES 3

Vaishnavi Lathk
Mega Sage
Mega Sage

 

Using a Catalog Client Script

  1. Ensure your variable set is set up: Make sure you have an MRVS variable set defined in your catalog item.

  2. Use a Catalog Client Script: You can create a Catalog Client Script that processes the input data and populates the MRVS. Here’s a sample script you might use:

 

 
function addToMRVS() {
    var data = [
        { "meterialID": "1220000", "DescriptionID": "tandard qa", "Quantity": 1 },
        { "meterialID": "1220000", "DescriptionID": "tandard qa", "Quantity": 1 }
    ];

    // Get the MRVS variable name
    var mrvsVariableName = 'your_mrvs_variable_name'; // Replace with your actual variable name

    // Loop through the array and add records to the MRVS
    data.forEach(function(item) {
        // Create a new record in the MRVS
        var newRecord = {
            "meterialID": item.meterialID,
            "DescriptionID": item.DescriptionID,
            "Quantity": item.Quantity
        };
        
        // Push the new record to the MRVS
        g_form.addOption(mrvsVariableName, newRecord);
    });
}

// Call the function to add records when the form loads
addToMRVS();

Using Flow Designer

  1. Create a Flow: In Flow Designer, create a new Flow and use the trigger that suits your needs (e.g., when a catalog item is requested).

  2. Add Action: Use the "Create Record" action to create multiple records in the MRVS.

  3. Loop through your data: Use a "For Each" action to iterate over the array of data. In each iteration, create a new record in the MRVS variable set.

  4. Map your fields: Map the fields from your array to the fields in your MRVS. This is typically done by selecting the appropriate variable names in the action configuration.

Community Alums
Not applicable

Thanks for quick reply. unfortunately client script didn't work for me.

Community Alums
Not applicable
g_form.addOption(mrvsVariableName, newRecord); 

Might be this is not working....