Expand my Community achievements bar.

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

## Need help with a table

Level 1

Hi!

I have created an expanding table using subforms that adds a row or deletes a row with the click of a button.  I also need the rows to total, my problem is that the rows that are added are not being calculated.  I have the minimum set to three, and it picks up those, but when I add a row it doesn't add the value in it.  Any suggestions would be greatly appreciated....

1 Accepted Solution

Former Community Member

The FormCalc sum functions can be used to total columns in all rows, where all rows have the same name. If you name each row uniquely you cannot take advantage of this function.

// form1.page1.subform1.table.row[1].totalWins::calculate - (FormCalc, client)

\$.rawValue = sum(form1.page1.subform1.table.row[*].wins)

See the attached.

Steve

7 Replies

Former Community Member

The FormCalc sum functions can be used to total columns in all rows, where all rows have the same name. If you name each row uniquely you cannot take advantage of this function.

// form1.page1.subform1.table.row[1].totalWins::calculate - (FormCalc, client)

\$.rawValue = sum(form1.page1.subform1.table.row[*].wins)

See the attached.

Steve

Level 10

Attached sample can help you.. It also has minimum 3 rows at the initialization and then you can add rows at run time.

Thanks

Srini

Level 4

Steve,

A non-repeating(static) table automatically names its rows, Row1, Row2,... RowN.  Is there a clean way to sum them?

I have Row1 + Row2 +.. RowN  for 21 rows.

It works, but is very tedious (and unsightly).  Is there a cleaner way to sum them?

Level 10

The below code can help you get access to each row inside a static Table. You can put your processing statements inside the If condition where I placed the messageBox statement.

for (i=0;i<Table1.nodes.length;i++){
if(Table1.nodes.item(i).name.substr(0,3)=="Row")
xfa.host.messageBox(Table1.nodes.itemi).name);
}

Thanks

Srini

Level 4

Srini,

Very nice.  Very nice.  Your answer has taught me some new properties of the table object, as well as the substr (method?) (function?).  Thank you.

Level 10

To make use of FormCalc wildcards I go in and rename the rows to have the same so that they gain instance numbers.

Level 4

Smart.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '\${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----