• Resolved Markus

    (@markusgt)


    I am thrilled to see that in your common actions you permit a condition. My question is what sort of conditions, and how do you articulate them? Specifically, can we not only compare for an exact match, but to see if one field contains one or more values of another field? Much like the conditional statements to show or hide a field do. But this time to change the value of a field, instead of to show or hide it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Markus

    (@markusgt)

    And if so, what is the proper syntax to use?

    Thread Starter Markus

    (@markusgt)

    I have figured out how to hide a field in css, the css is

    #id {
    display: none;
    }

    Now I just need a way to compare what my user entered against that field, to see if [HiddenField] contains [UserEntry]

    • This reply was modified 7 years, 5 months ago by Markus.
    Plugin Author EDGARROJAS

    (@edgarrojas)

    Hello!

    Sorry the common actions doesn’t have a ‘contains’ action. There is going to be one in the future which will have the format of [field rnField1].contains([field rnfield2]) but for now this can be done with something like this (which is very complex… sorry for that):

    (function(){
    if([field rnField6].label!=” && [field rnField2].label.indexOf([field rnField6].label)!== -1)
    return ‘Match’
    return ‘Does not match’;
    }())

    please replace rnField2 for the id of the field that have the full string and rnfield6 for the substring that you want to search.

    Is that what you need?

    Thread Starter Markus

    (@markusgt)

    Thank you for the code. That does look close. But though I am not a coding expert, somethings look a bit off with your code above

    this section:

    return ‘Match’
    return ‘Does not match’;

    just looks like it needs something (a comma, semicolon?) to differentiate between the two.

    AND

    When I put this code

    (function(){
    if([field FullName].label!=” && [field FITPProductionTeamList].label.indexOf([field FullName].label)!== -1)
    return ‘Match’
    return ‘Does not match’;
    }())

    into the formula, I get “An error occurred
    SyntaxError: identifier starts immediately after numeric literal”

    And if I need to put it not into the formula for the value but instead into the main javascript for the form, please include the elements needed to place the value into the third field [field FITPProductionTeamMemberTest].

    • This reply was modified 7 years, 5 months ago by Markus.
    Plugin Author EDGARROJAS

    (@edgarrojas)

    You are right, i forgot to add a semicolon, try with this:

    (function(){
    if([field rnField6].label!=” && [field rnField2].label.indexOf([field rnField6].label)!== -1)
    return ‘Match’;
    return ‘Does not match’;
    }())

    The formula is kind of complex and the validator will fail (it is unable to understand the .label thing that need to be used) but the formula should work, i tested it in a form.

    Regards!

    Thread Starter Markus

    (@markusgt)

    Shucks. It is reporting “undefined” as the result. I was careful to copy the fields carefully into the formula and have double checked it.

    Thread Starter Markus

    (@markusgt)

    (function(){
    if([field FullName].label!=” && [field FITPTeamList].label.indexOf([field FullName].label)!== -1)
    return ‘Match’;
    return ‘Does not match’;
    }())

    Thread Starter Markus

    (@markusgt)

    I am noticing in your code though that you only use one double quote. Should there be two?

    • This reply was modified 7 years, 5 months ago by Markus.
    Thread Starter Markus

    (@markusgt)

    But I don’t think that’s the issue

    • This reply was modified 7 years, 5 months ago by Markus.
    Thread Starter Markus

    (@markusgt)

    HOWEVER… This has created a work-around for me.

    Because field FITPTeamList].label.indexOf([field FullName].label) DOES work…

    providing me with a field that shows either a 0 if there is a match, or a -1 if there is not.

    Then I can use your Conditionals to show or hide a separate html field to reveal the “match” “does not match” side of things.

    Plugin Author EDGARROJAS

    (@edgarrojas)

    Alright, this should return a 0 when there is a match and -1 when not:

    (function(){
    if([field rnField6].label!=” && [field rnField2].label.indexOf([field rnField6].label)!== -1)
    return 0;
    return -1;
    }())

    Regards!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Formulas – Can they compare based on “contains”?’ is closed to new replies.