Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Create Unique records from multi row variable set

Amrutha K V
Tera Contributor

Hi 

We have a Multi-Row Variable Set (MRVS) named "MRP PRODUCTS PLANNING". Inside this variable set, there is a select box variable called "Plant & Storage Location" . 

Users should be allowed to create only one record for each value in the dropdown. If there are only ten  available drop down values, a maximum of ten records should be created in the MRVS. Duplicate selections should not be allowed, and users should not be able to create multiple records with the same Plant & Storage Location value.
How can we implement this functionality?

Thank you

 
6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Amrutha K V 

how and from where you are creating the records from MRVS?

Flow or workflow or business rule?

there you can add logic

show your MRVS variables form

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

We are getting the drop down for Plant and storage location field from a multiline text variable which is present outside the MRVS. 
For getting the value we are using OnLoad Catalog Client Script:


function onLoad() {

    // Get value from parent form
    var parentValue = g_service_catalog.parent.getValue('storage_location_outside');
    //alert('Value: ' + parentValue);

    if (!parentValue)
        return;

    //  Split comma-separated string into array
    var values = parentValue.split(',');

    //  Clear existing options first
    g_form.clearOptions('plant_storage_location');

    //  Add default option
    g_form.addOption('plant_storage_location', '', '-- None --');

    //  Loop through array (correct way)
    for (var i = 0; i < values.length; i++) {

        var val = values[i].trim();  // remove extra spaces

        if (val) {
            g_form.addOption('plant_storage_location', val, val);
        }
    }
}

@Amrutha K V 

see my below response

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

Ankur Bawiskar
Tera Patron

@Amrutha K V 

approach to take

1) limit MRVS to 3 rows, see this link

2) On the select box variable Plant & Storage Location inside the MRVS:

Set Unique = true.

Keep it Mandatory = true

3) use catalog client script onSubmit to validate the MRVS JSON

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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