Problem With the Conditional Logic

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1722
    Joe McShea
    Keymaster

    For starters, big fan of this product. Thank you for the great work on it.
    I’m having problem with the conditional logic and hoping for some help. I have a list which are checkboxes so multiple is possible. For simple terms, let’s just say choices are A, B, C and D, with D being an Other with a write in. If someone chooses B then question XX is to appear. If it’s the other three, it’s hidden. Simple enough. However, since it’s checkbox, I’m trying to give the condition if B is ONE of the choices, then show the field. I feel I’ve tried every conceivable method and it either ends up showing question XX no matter what is checked, or it will show XX when only B is selected but not if the others are too. Is this something you can help with? Thanks in advance!

    Posted by GST.

    • This topic was modified 2 years, 4 months ago by Joe McShea.
    #1724
    Joe McShea
    Keymaster

    First, the problem is complicated by the simplicity of your example, meaning A, B, C, and D aren’t verbose enough to easily distinguish from a user entered value because of the way multi-choice values are seen by SPEasyForms. So SPEasyForms sees the value of a multi-choice field as being all of the choices chosen, concatenated by a semi-colon, so if you selected A, C, and entered a fill-in choice of bob, the value would look like:

    A; C; bob

    You can see this yourself by making the multi-choice field read-only in edit forms and then looking at it in the edit form. Whatever SPEasyForms displays for read-only is the same string used in conditional expressions.

    Anyway, that’s problematic, because given your requirements, the only conditional operator that will work for you is matches. This is because I only allow you to set conditions on the entire value, not parts of a multi-valued field. So given the example, you’re expression would be show the field when “MultiChoice matches B”, but of course “A; C; bob” matches B (as will any string that contains a B).

    Ideally, your values are actually more verbose than that, but to keep it simple I’ll change them to {A}, {B}, {C}, or a fill-in. So now I can create two rules:

    1. Show field XX when MulitChoice matches {B}
    2. Hide field XX (with no conditions, just hide it all the time by default)

    This should work the way you want it to.

    Now if you’re not so lucky and you really can’t always distinguish B from a fill-in, then you have to get wiggy’ with regular expressions and try to identify an exact match for B. So dropping the curly braces and going back to the original example of A, B, C, and/or a fill-in, something like this should work:

    1. Show field XX when MulitChoice matches (^| )B(;|$)
    2. Hide field XX (with no conditions, just hide it all the time by default)

    Breaking that down, it’s something like:

    • (^| ) – this expression matches anything that starts a line or is preceded by a space.
    • B – of course literally matches the letter B, but keep in mind that SPEasyForms does all conditional logic case-insensitive.
    • (;|$) – this expression matches anything that ends with a semi-colon or ends a line.

    So this effectively matches “B” (starts and ends a line), “A; B; C” (contains a B staring with a space and ending with a semi-colon), “B; C” (starts a line and ends with a semi-colon), etc.

    Now admittedly, if your user choses A and C and a fill-in value in which they typed B, the final result would be “A; C; B” which would match, but at this point they’re just asking for trouble so let them have it ;).

    Joe

    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
    • This reply was modified 2 years, 4 months ago by Joe McShea.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Scroll to top