How to populate a multi row variable set based on selected variables in a catalogue item

matthew_hughes
Kilo Sage

I'm the below catalogue item where users have to select their options:

matthew_hughes_0-1734002543946.png

 

On the final part of my catalogue item, I have a multi row variable set where I'm wanting to add the selected details:

matthew_hughes_1-1734002620870.png

 

Does anyone know how I need to populate my multi row variable set with the selected options?

 

1 ACCEPTED SOLUTION

matthew_hughes
Kilo Sage

I removed an if statement from my script include which was causing an issue.

View solution in original post

19 REPLIES 19

Hi @Ankur Bawiskar  This is the client script that I'm using:

matthew_hughes_0-1735038595927.png

function onChange(control, oldValue, newValue, isLoading) {
    //If form is loading, do nothing
    if (isLoading) {
        return;

    //If the list of Business Applications to update is cleared, clear the Multi Row variable set
    } else if (newValue == '') {
        g_form.setValue('selected_business_applications', []);
   
    //Each time a Business Application is added, add a row for each Business Application with the other variables
    } else {
        var businessApplications = g_form.getDisplayValue('business_applications_to_update');
        var businessApplicationNumber = g_form.getReference('business_applications_to_update');
        var currentPlatform = g_form.getDisplayValue('current_owning_platform');
        var newPlatform = g_form.getDisplayValue('new_platform');
        var newLab = g_form.getDisplayValue('new_lab_department');
        var appsArr = businessApplications.split(',');
        var apps = [];
        for (var i = 0; i < appsArr.length; i++) {
            apps.push({
                'current_business_owning_platform_variable_set': currentPlatform,
                'new_platform_variable_set': newPlatform,
                'new_lab_level_platform_child_variable_set': newLab,
                'business_application_owner_variable_set': applicationOwner,
                'business_application_name_variable_set': appsArr[i],
            });
        }
        g_form.setValue('selected_business_applications', JSON.stringify(apps));
    }

}
 
However, this is what I notice when I select multiple business applications on my catalogue item:
matthew_hughes_1-1735038751156.png

I'm wanting the Business Application Number and Business Application Owner columns to be populated as well with the details from the selected business applications. Do you know what I need to include my client script?

@matthew_hughes 

simply fetch the value from the table's field and set in json

I could see you are already setting the business_application_owner_variable_set is that not what you want?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

I'm trying to get the value to that field, but it returns as blank.

@matthew_hughes 

please use GlideAjax as you will have to query the table and get the values

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

@matthew_hughes 

 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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