Most SOM expressions I work with have an absolute index number, something like form1[0].[0].Table1[0].Row1[0].TextField1[0] where all the numbers within the square brackets are absolute numbers. But these numbers can be relative, that is have a positive or negative sign. So if I was on TextField1 of row 2 and wanted to reference TextField1 of row 1 I could use a SOM expression like;
Row1.resolveNode('Row1[-1].TextField1');
Similarly if I have a series of fields with the same name and so have different indexes, say TextField[0], TextFIeld[1] etc, I can reference the next field, in document order, called TextField with a SOM expression
this.resolveNode('TextField[+1]').rawValue
We can also refer to the next field without knowing it's name using the class name reference (that is with a "#" character).
this.resolveNode('#field[+1]').somExpression
or the next button
this.resolveNodes('#field.(ui.oneOfChild.className == "button")').item(1).somExpression
This sample gives examples of these expressions and uses a relative SOM expression to calculate a running total in a table.
RelativeIndex.pdf
No comments:
Post a Comment