How to repeat catalog variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 08:51 PM
Hi,
Have use case which need to repeat the previous variables in service catalog.
For Example:
My catalog has 46 variables:
Based on the input given as yes on 46 th variable I need to repeat the variables from 33 to 46 again. Please let me know how we can achieve this.
Thanks
Srini
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2022 12:34 AM
Not sure what's the question is asking. Is the question about creating variables on the form or about showing/hiding variables based on selection on the 46th variable?
If the question is about defining variables on a form, define variable 33 but instead of pressing the "Update" button, right click on the head area and select "Save". Change the "Name" and "Order". Right click on the header area and select "Insert". Repeat for variables 34 to 46.
If the question is about showing/hiding variables, the easiest way I know is to name fields "field1" to "field46" and then to use client script to show/hide variables. By "repeat", is there going to be 60 fields when the variable 46 is true? If so, create variables named field1 to field60 and create an onChange() on variable 46.
For example:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var display_flg = (newValue == 'Yes'); // When the variable type is "Yes/No"
for (var i = 47; i <= 60; i++) {
g_form.setDisplay('field' + i, display_flg); // show and hide variables
}
}
If the variable names can't be named consecutively, use the following script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var display_flg = (newValue == 'Yes'); // When the variable type is "Yes/No"
var variable_list = ['variable47', 'variable48']; // list of variable names to show/hide
for (var i = 0; i <= variable_list.length; i++) {
g_form.setDisplay(variable_list[i], display_flg);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 03:19 PM