-
Hi, I have a map where I need to sum the attribute values called "upd". It is a % of advancement. Now the question I cannot answer: my formula works well always except when it is accounting a node with the same formula inside the upd value generating an error: which is the mistake? How to correct this formula? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I tried a different formula, but I got the same problem as above: see the zip file this formula fails when summing up nodes with the same formula inside their upd attribute value |
Beta Was this translation helpful? Give feedback.
-
In the following code, def updAttribute = child.attributes.find { it.key == 'upd' }
return updAttribute ? updAttribute.value : 0 To get the result of the formula evaluation, you can use either def updAttribute = child.attributes.transformed.find { it.key == 'upd' }
return updAttribute ? updAttribute.value : 0
def updAttributeList = child.attributes.findValues { key, value -> key == 'upd' }
return updAttributeList ? updAttributeList[0].num : 0 The above can be simplified. return child['upd'].num0 |
Beta Was this translation helpful? Give feedback.
-
Thank you macmarrum, it works finely. |
Beta Was this translation helpful? Give feedback.
In the following code,
.value
gets you the raw value of the attribute, which in your case is the formula's text.To get the result of the formula evaluation, you can use either
.getTransformed()
or.findValues
.findVlaues
will return a list ofConvertible
The above…