Displaying a Confiform field as currency with background "set expression" calculations

Jason Walsh
Contributor
March 8, 2021

Looking to see if this is possible. I have a simple form with user input fields for currency amounts. For the sake of example let's say I have (field1 + field2) / 3 = field3 where fields 1 and 2 are user input and field3 is based on the set expression rule of field1 + field2. What I really want is for my front end user to see the fields they input populate as $123,456.78 not 123456.78. Additionally, my form has division based math behind some of the fields and I want to force the result to 2 decimal places. I know that if set as a currency field using masking formatting I can get to this as a confiform record, but really need to display this at face value in the form. I've had some marginal success using JS but this ultimately breaks any math driven fields. Is this possible? Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2021

Hi

Take a look at this screencast, it uses ConfiForms Field Definition Rules macro to calculate the expression online and sets it on a readonly field in a form...

http://recordit.co/ooIVxj0SoR 

The expression I have is 

field3=(CONCAT("$", FORMATNUMBER(([entry.field1] + [entry.field2])/3,"###,###.00")))

Hope this helps

Alex

Jason Walsh
Contributor
March 8, 2021

This is great Alex!

I assume that I can adopt the same logic for fields 1 and 2 (ex: !field1[empty]) something like that? or will that cause problems if the user makes an edit to a preexisting value?

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2021

Not sure I understand your question... the rule I have only kicks in when both fields have values... see the condition I have for the rule in my screencast

Jason Walsh
Contributor
March 8, 2021

Sorry Alex, I think I phrased that poorly. 

So how would I plug that logic into a simple user input field that is void of calculations? In my example of field1 + field2 = field3, let's say I wanted to "display" field1 and 2 as $123,456.78 while still being able to facilitate the calculation to field3?

Jason Walsh
Contributor
March 13, 2021

After looking into it a bit, I don't think that setting a field to display as "currency" will work with back end calculations being set. 

That being said, I do have a follow up question as I'm beginning to plug in some logic to do mat operations on the backend. 

I'm attempting to use an IF statement to "set expression" for another field. 

 

Here's a couple of examples I've attempted. Also all fields are set to numeric and "var1" is the result of a "set expression" rule to calculate itself. 

So this works:

Field Name - newmtgflex,dischargeamt

Condition - !newmtgflex:[empty] AND !dischargeamt:[empty]

Values to set - var1=([entry.newmtgflex]/[entry.dischargeamt])

This doesn't work

Field Name - newmtgflex,dischargeamt,var1,penaltypaid

Condition - !newmtgflex:[empty] AND !dischargeamt:[empty] AND !var1:[empty] AND !penaltypaid:[empty]

Values to set - var2=IF([entry.var1]:<=1,([entry.newmtgflex]/[entry.dischargeamt])*[entry.penaltypaid],[entry.penaltypaid])

 

I'm probably missing something obvious, let me know if you can help me out, thanks!

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2021

Hi

I think you are missing the quotes to help ConfiForms to recognize the arguments

var2=IF("[entry.var1]<=1","([entry.newmtgflex]/[entry.dischargeamt])*[entry.penaltypaid]","[entry.penaltypaid]")

See Math operations in ConfiForms 

Alex

Jason Walsh
Contributor
March 15, 2021

I had thought about this over the weekend and thought that it was something that I had missed with the quotes around the variables. Tested and works, thank you so much Alex. 

Upping the difficulty level, I imagine that a nested IF statement would follow the same logic? 

IF("[entry.var1]<=1",IF("(([entry.newmtgflex]/[entry.dischargeamt])*[entry.irdamt])<1000",
"([entry.newmtgflex]/[entry.dischargeamt])*[entry.irdamr]",1000),"[entry.irdamt]")

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2021

Yes, you can nest expressions... just be careful with parenthesis match. as it becomes very quickly very "dirty"

Jason Walsh
Contributor
March 15, 2021

Hehe, yeah I'm realizing that quickly, again, Alex, thanks for putting me back on the right path. :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events