Copy multiple variable values into one variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 12:09 AM
Hello Everyone,
I've a requirement to Copy multiple variable values into one variable. Kindly refer the attached screenshot, in that i would like to copy the "Company", "Available Manufacturers", "Available Locations", etc variable values into "Selected values" variable one by one. Did anyone achieved similar kind of requirement?
Regards,
Arun

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 12:49 AM
Hello @arundharmabe,
To copy multiple variable values into one variable, you can use a Catalog Client Script or a Business Rule to concatenate the values of the source variables and assign them to the target variable. For example, you can use the following script in a Catalog Client Script on the Catalog Item:
//Get the values of the source variables
var company = g_form.getValue(‘company’);
var manufacturers = g_form.getValue(‘available_manufacturers’);
var locations = g_form.getValue(‘available_locations’);
//Concatenate the values with a separator
var selected_values = company + ’ | ’ + manufacturers + ’ | ’ + locations;
//Set the value of the target variable
g_form.setValue(‘selected_values’, selected_values);
//Get the values of the source variables
var company = current.variables.company;
var manufacturers = current.variables.available_manufacturers;
var locations = current.variables.available_locations;
//Concatenate the values with a separator
var selected_values = company + ’ | ’ + manufacturers + ’ | ’ + locations;
//Set the value of the target variable
current.variables.selected_values = selected_values;
This script will run when a new record is inserted in the Requested Item table, and copy the variable values to the target variable.
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 02:08 AM
Hi Swarnadeep,
Thanks for the response. For my case BR won't work because it is before submission of the catalog. I tried with the catalog client script but it didn't worked. I am only getting the company value as the output.
Below is the code which i tried(getValue only get's the sys_id, so i've used getDisplayBox to get the display value of the reference variable).
var comp = g_form.getDisplayBox('customer_company').value;
var loc = g_form.getDisplayBox('location').value;
var selected = comp + '|' + loc;
g_form.setValue('selected_values', selected);
Regards,
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 06:38 AM
@Ankur Bawiskar Could you please advise on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 07:02 AM - edited 08-18-2023 07:03 AM
worked for me, tested on incident form , for Caller and Assignment group field.
My script screenshot