• Resolved niggo

    (@niggo)


    Hi!

    I have a calculated field that should be empty (or shows 0), as long as its value is less than 0.8.

    When you look on the site (user: future, password: ticket) you see the field ‘Ticketgebühr’. This should be empty (or 0) as long as ‘Ticketpreis’ is empty.

    I’ve defined dependencies like this

    If value is Less than 0.8
    If rule is valid show fieldname11

    ‘fieldname11’ is a hidden field with value 0. That doesn’t work.

    I’ve tried to set it to ‘fieldname7’ which is the ‘Ticketpreis’ field because I thought, that this would have an empty result as long as the field is empty. That didn’t work as well.

    Nothing changes no matter what I choose at ‘If value is…’ and ‘If rule is valid show …’.

    • This topic was modified 3 years, 5 months ago by niggo.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter niggo

    (@niggo)

    Actually I had to clear the dependencies section because that crashes the site…

    Plugin Author codepeople

    (@codepeople)

    Hello @niggo

    First, a control type Hidden will never be visible because its default state is hidden.

    Now, defining fieldname7 as dependent on the same equations that use it generates an infinite loop.

    I’ll try to describe how the plugin works. Every time you modify a field’s value, the plugin identifies all the equations affected by this field and evaluates them. However, after evaluating the equations, the values of the calculated fields vary, and the plugin repeats the process to identify the equations affected by the new fields whose values change. The process is repeated again and again until no field varies its value.

    So, if you use the field A in its own equation, you have created an infinite loop. If you use field A in the equation of field B, and field B in the equation of field A, you have created an endless loop. The chain can be longer, using field A in the equation of field B, field B in the equation of field C, and field C in the equation of field A, closing the circle.

    Something similar happens with the equations. The values of the disabled dependent fields are zero, but once the field is activated its value change to the current one.

    So, if the fieldname7 field is used in the equation and depends on the equation’s result, you have created an infinite loop.

    I’m not sure about the equation you want to implement. However, if your current equation is:

    fieldname6=='inkl'?fieldname7-fieldname8:fieldname4-fieldname7

    but you want to return an empty result if fieldname7 is empty, you can edit the equation as follows:

    IF(fiedlname7, IF(fieldname6=='inkl', fieldname7-fieldname8, fieldname4-fieldname7), '')

    As you can see, I’ve nested two IF operations.

    Best regards.

    Thread Starter niggo

    (@niggo)

    I didn’t see that an IF operation is possible. Thanks for that. Works perfectly!

    Plugin Author codepeople

    (@codepeople)

    Hello @niggo

    Yes, you can use the IF operation, but the process would be the same with the ternary operator:

    fiedlname7 ? (fieldname6=='inkl' ? fieldname7-fieldname8 : fieldname4-fieldname7) : '';

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Field empty if value is less than 0.8’ is closed to new replies.