How to fetch the input value variable and set that value into variable of variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:19 PM
Query: How to fetch the input value of catalog item variable and set that value into variable of variable set which are both placed in the same catalog item.
Consider
1)"u_name" is catalog item variable (not part of that variable set)
u_name = Servicenow
2)"u_id" is catalog item variable (not part of that variable set)
u_id =7766889
3) u_details =
now value of u_name and u_id should be display in variable of variableset i.e u_details
Note- u_details is part of variable set which is in same catalog item
FINAL OUT PUT=u_details = Servicenow_7766889
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 12:49 AM - edited 12-07-2023 01:01 AM
Hi,
You need to create two onChange catalog client scripts as shown below:
1. Set u_details - on change of u_name:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Fetch the values of u_name and u_id
var u_name = g_form.getValue('u_name');
var u_id = g_form.getValue('u_id');
// Concatenate u_name and u_id and set the value of u_details
var u_details_value = u_name + '_' + u_id;
g_form.setValue('u_details', u_details_value);
}
2. Set u_details - on change of u_id
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Fetch the values of u_name and u_id
var u_name = g_form.getValue('u_name');
var u_id = g_form.getValue('u_id');
// Concatenate u_name and u_id and set the value of u_details
var u_details_value = u_name + '_' + u_id;
g_form.setValue('u_details', u_details_value);
}
Please mark it helpful, if I answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:06 AM
Hi @Iraj Shaikh
Thanks for your response.
the script which you provided work perfectly only for variables.
But,
Here u_name and u_id both are variables, u_details is part of variable set variable. now the requirement is the input of two variables should be display in variable set variable i.e u_details.
the script which you provided work for variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:19 AM - edited 12-07-2023 01:22 AM
Hi @Sravan33
The catalog client scripts above contains u_details variable and it is part of a variable set.
It works. I have tested in my PDI.
Please mark it helpful, if I answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:35 AM
Hi,
Please use the below script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Fetch the values of u_name and u_id
var u_name = g_form.getValue('u_name');
var u_id = g_form.getValue('u_id');
// Concatenate u_name and u_id and set the value of u_details
var u_details_value = u_name + '_' + u_id;
g_form.setValue('<variable set internal name>.u_details', u_details_value);
}
