UiPath Apps - 'SUM' is not declared. It may be inaccessible due to its protection level

When you use SUM function in UiPath Apps, you may encounter this error ''SUM' is not declared. It may be inaccessible due to its protection level.'

Issue Description

SUM function may provide the following error in UiPath Apps.

'SUM' is not declared. It may be inaccessible due to its protection level.

Example:

Resolution

To get the sum of any list type objects, the below syntax can be used.
With VB language, sum and other LINQ capabilities are available out-of-the-box.


It should also update when control data is updated.

There is, however, a limitation that we can only operate on data available on Apps. It won't give you the sum from Data Fabric entities.

Example:

pgSum.EditGrid.DataSource.data.Where(Function (x) x.testcolumn = "Y").Sum(Function (y) y.amt.Value).ToString

  • pgSum.EditGrid.DataSource.data Refers to the full dataset currently displayed or bound to the Edit Grid control named pgSum.

  • .Where(Function (x) x.testcolumn = "Y") Filters the dataset to include only rows where the value of testcolumn is "Y".

  • .Sum(Function (y) y.amt.Value) Sums the Value field inside the amt property for each of the filtered rows.

  • .ToString Converts the resulting numeric sum into a string format, likely for display in a label or text field.

What It Achieves?

It calculates the total amount (amt.Value) for all rows in the Edit Grid where testcolumn equals "Y", and returns that total as a string.