Using a rule with an if statement

I have a rule that uses an if statement  similar to the example below:

 

if(ri!firstName="John", "Manager", if(ri!firstName="Mary","CEO", if(ri!firstName="Bob","VP","")))

 

The only problem is that if a person is not John, Mary, or Bob, I do no want to store a blank or anything else. I literally want the false parameter to do nothing. The reason is if the person filling out the form clicks on the Previous button, any value they entered in the blank field is lost every time the rule is applied.

 

Thank you,

 

Tony

 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Tony,

    How about using the below mentioned code snippet:

    if(
      ri!firstName = "John",
      "Manager",
      if(
        ri!firstName = "Mary",
        "CEO",
        if(
          ri!firstName = "Bob",
          "VP",
          ri!firstName
        )
      )
    )

    As per this above snippet, if ri!firstName is not in (John, Mary and Bob) then instead of setting null/{}/"" and loosing the input value, you can return the same input value i.e. ri!firstName.

    I am not sure whether are you looking for the same sort of solution or not, but in this case, when you navigate to the previous page, then you will have the same value as what you have provided and not in (John, Mary and Bob). And also, if you are using conditional statement means, you are supposed to store a value in either case, either it can be a null or a value.

Reply
  • 0
    Certified Lead Developer

    Hi Tony,

    How about using the below mentioned code snippet:

    if(
      ri!firstName = "John",
      "Manager",
      if(
        ri!firstName = "Mary",
        "CEO",
        if(
          ri!firstName = "Bob",
          "VP",
          ri!firstName
        )
      )
    )

    As per this above snippet, if ri!firstName is not in (John, Mary and Bob) then instead of setting null/{}/"" and loosing the input value, you can return the same input value i.e. ri!firstName.

    I am not sure whether are you looking for the same sort of solution or not, but in this case, when you navigate to the previous page, then you will have the same value as what you have provided and not in (John, Mary and Bob). And also, if you are using conditional statement means, you are supposed to store a value in either case, either it can be a null or a value.

Children
No Data