Confiform "Set expression" does not work when field is updated by backspace
Asked by Alice Liu:

Hi Team,

I have set below structure for users to input several fields, and provide a total using Field Definition Rules with "set expression" to calculate total. The total can be successfully calculated in the beginning.

However, the problem is that if user updates any field with "backspace" instead of input "0," the "set expression" rule seems can not work and will return below message:

"COM.VERTUNA.CONFLUENCE.PLUGINS.CONFIFORMS.UTIL.EXPRESSION$EXPRESSIONEXCEPTION: TOO MANY OPERATORS OR FUNCTIONS AT: +"

It is weird because if user input "0," then the total can be calculated correctly. I have tested multiple times, and seems only "backspace" would cause the calculation fail.

Could you advise?

Ps. The structure:

- Field A: $user input amount

- Field B: $user input amount

- Fied C: read-only to display calculated result

- Rule 1 for Field A (calculate total when there is input):

condition = empty

action = set expression

value = Field C = \[entry.Field A\] + \[entry.Field B\]

- Rule 2 for Field A (put "0" when there is no input):

condition = empty

action = set value if empty

value = Field A = 0

Rules on Field B is similar to on Field A.


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Alice Liu](/t5/user/viewprofilepage/user-id/5213119) and welcome to this community

Fix your expression to handle the empty value

```
FieldC=ZEROIFEMPTY("[entry.FieldA]") + ZEROIFEMPTY("[entry.FieldB]")
```

Alex

comments: author: Alice Liu
body: Hi Alex,

Thanks for the greeting and prompt reply!

I may not express my question clearly, but I did not set empty value rule on Field C.

The empty value "0" rule is set on Field A and Field B.

And my problem is that if in the beginning user input:

Field A = 100

Field B = 100

Then Field C can correctly display total 200.

But if then user use "backspace" to eliminate Field A's or Field B's value, then Field C will show the COM.VERTUNA message stated in my above post.

i.e. if afterwards user input:

Field A = 100 \>\> empty (using "backspace" instead of input "0")

Field B = 100

Field C = COM.VERTUNA.CONFLUENCE.PLUGINS.CONFIFORMS.UTIL.EXPRESSION$EXPRESSIONEXCEPTION: TOO MANY OPERATORS OR FUNCTIONS AT: +

But if user input Field A = 100 \>\> 0, then Field C will show 200.

Hope this example explain better. Could you help to see what I can change to solve this problem?


author: Alex Medved _ConfiForms_
body: OK, and that is exactly what I was trying to help you with...

Let me try with the demo this time, I hope it helps

<http://recordit.co/nAxvkpVRpp>

Alex


author: Alice Liu
body: Hi Alex,

The demo is very clear and helpful. I tried on my case and the problem is solved.

Thank you!


author: Jonathan Saldarriag
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) I am getting this error:

Expression: \[\*\] could not be calculated, Too many operators or functions at: \*

and in some of the entries a 2 appears:

Expression: \[\*2\] could not be calculated, Too many operators or functions at: \*

The expression is quite simple and in some of the entries it works. The form itself is quite long, but the calculated field is only a multiplication between two fields:

![Screenshot 2024-04-23 at 16.43.57.png](https://community.atlassian.com/t5/image/serverpage/image-id/320077i44D3E903FA7B9973/image-size/large?v=v2&px=999 "Screenshot 2024-04-23 at 16.43.57.png")

Then for evaluationIT we have:

![Screenshot 2024-04-23 at 16.45.50.png](https://community.atlassian.com/t5/image/serverpage/image-id/320086i7220DB02C6B178E7/image-size/large?v=v2&px=999 "Screenshot 2024-04-23 at 16.45.50.png")

Then for evaluationDPO we have:

![Screenshot 2024-04-23 at 16.46.08.png](https://community.atlassian.com/t5/image/serverpage/image-id/320081i97F446B943297B0A/image-size/large?v=v2&px=999 "Screenshot 2024-04-23 at 16.46.08.png")

And finally the calculated field is:

![Screenshot 2024-04-23 at 16.46.22.png](https://community.atlassian.com/t5/image/serverpage/image-id/320082i8B437CF586E011AF/image-size/large?v=v2&px=999 "Screenshot 2024-04-23 at 16.46.22.png")

comments: author: Alex Medved _ConfiForms_
body: I believe what you are looking for is actually a formula field, not calculated - unless you want to calculate this only once, on record creation, and never recalculate

And to handle empty values, as explained in the comments here you will need to wrap the field values in the ZEROIFEMPTY functions

```
ZEROIFEMPTY("[entry.evaluationDPO]") * ZEROIFEMPTY("[entry.evaluationIT]")
```

Aex


author: David C
body: Hey [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) , I am having an issue converting this to multiplicative form.

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/313661i4B8A4DF867ABCC6E/image-size/large?v=v2&px=999 "Capture.PNG")

I have the following built with the following formula  
MasterTechAgencyFee=ZEROIFEMPTY("\[entry.MasterTechAgencyRate.masterpickagencyagencyrate\]")\*ZEROIFEMPTY("\[entry.MasterTechAgencySalaryRequirement\]")

Where the Agency Rate field is a smart field reference to another form (i.e. why I have .masterpickagencyrate on the end)  

this should be providing an answer of 2 (100,000\*.0002) but is instead providing 200,000 as the the answer.

comments: author: Alex Medved _ConfiForms_
body: Sorry, but please provide a mathematically valid number - 0.0002


author: David C
body: I'm attempting to multiply it by 20% (however.02 also did not work), (20%\*100,000=20,000). I'm unsure of how .00002 is not a mathematically viable number?


author: Alex Medved _ConfiForms_
body: instead of .00002 put 0.00002


author: David C
body: Thanks as always Alex, that seemed to do the trick.


author: Alex Medved _ConfiForms_
body: You are very welcome!


Tags: confiforms