Set value outside Multi Row Variable Set

Guilherme Popo2
Tera Contributor

Hello Guys!

 

In Service Portall, I have a Variable Set Multirow that has a text field called "Ports".
If the "Ports" field has the number 22, it defines a selectbox variable outside the Multirow as "YES", however, I am not able to make this value change in this selectbox variable.

 

 

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
   
  var getPortValue = g_form.getValue('ports');

    if (getPortValue.includes("22")) {

        alert(getPortValue);
        g_form.setValue('port_22_normal', 'yes');

    }
   
}

 

 

 

1 ACCEPTED SOLUTION

Yashsvi
Kilo Sage

Hi @Guilherme Popo2,

Sure, here is a concise version of your script that handles the multi-row variable set to check for the value "22" in the "Ports" field and sets the selectbox variable accordingly:

function onSubmit() {
var multiRowValues = g_form.getValue('multi_row_variable_set'); // Replace with the actual variable set name
var containsPort22 = false;

multiRowValues.forEach(function(row) {
if (row.ports.includes("22")) { // Replace 'ports' with the actual field name
containsPort22 = true;
}
});

if (containsPort22) {
g_form.setValue('port_22_normal', 'YES'); // Replace with the actual selectbox variable name
}
}

 Replace the placeholders:
- `'multi_row_variable_set'` with your actual multi-row variable set name.
- `'ports'` with the actual name of the "Ports" field.
- `'port_22_normal'` with the actual name of the selectbox variable.

 

Thank you, please make helpful if you accept the solution.

View solution in original post

2 REPLIES 2

Yashsvi
Kilo Sage

Hi @Guilherme Popo2,

Sure, here is a concise version of your script that handles the multi-row variable set to check for the value "22" in the "Ports" field and sets the selectbox variable accordingly:

function onSubmit() {
var multiRowValues = g_form.getValue('multi_row_variable_set'); // Replace with the actual variable set name
var containsPort22 = false;

multiRowValues.forEach(function(row) {
if (row.ports.includes("22")) { // Replace 'ports' with the actual field name
containsPort22 = true;
}
});

if (containsPort22) {
g_form.setValue('port_22_normal', 'YES'); // Replace with the actual selectbox variable name
}
}

 Replace the placeholders:
- `'multi_row_variable_set'` with your actual multi-row variable set name.
- `'ports'` with the actual name of the "Ports" field.
- `'port_22_normal'` with the actual name of the selectbox variable.

 

Thank you, please make helpful if you accept the solution.

Hello @Yashsvi Thank you so much, It worked