Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Using variable/s in SOM expression... how?

Avatar

Former Community Member

Hello all,

Sometimes its the simplest things that are the most confusing (for me anyway). For example:

I have a static table in a form in which the cells in one column each contain a checkbox.

The reference for each checkbox would be:

Table1.Row1.ckbox[0]

Table2.Row2.ckbox[0]

Table3.Row3.ckbox[0]

and so on.

I have a button elsewhere on the form, which when clicked would set each of the checkboxes in the table to "1" or checked, and would uncheck them all when clicked again.So I'm thinking a simple for loop would do the trick.

var i

for i = 1 upto 12 do

     Table1.Row[i].ckbox = 1

endfor

               ---OR---

for (var row = 1; row < 13; row++)
    {
    form1.main.front.Table1.Row" + row + ".CheckBox = 1;
    }

Neither works.

Is it the syntax, or something else entirely? Any pointers to examples of how and when to use variables in SOM references would be extremely appreciated.

Thanks

Harry Ohm.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Harry,

You need to resolve the node in Javascript, so the following should work:

for (var i=1; i< 13; i++)

{
    xfa.resolveNode("form1.main.front.Table1.Row" + i + ".ckbox).rawValue = 1;
}

The way you have stated the name of the checkbox "Table1.Row1.ckbox[0]", indicates that there may be more than one ckbox in each row. If that is the case then you may need to replace .ckbox in the script with .ckbox[0].

Hope that helps,

Niall

Assure Dynamics

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi Harry,

You need to resolve the node in Javascript, so the following should work:

for (var i=1; i< 13; i++)

{
    xfa.resolveNode("form1.main.front.Table1.Row" + i + ".ckbox).rawValue = 1;
}

The way you have stated the name of the checkbox "Table1.Row1.ckbox[0]", indicates that there may be more than one ckbox in each row. If that is the case then you may need to replace .ckbox in the script with .ckbox[0].

Hope that helps,

Niall

Assure Dynamics