2 Replies Latest reply on Aug 15, 2011 10:03 AM by philmodjunk

    Conditional Multiple String Value

    JanX

      Title

      Conditional Multiple String Value

      Post

      Hi, I am a newbie in FM and I was trying to create script using If statement, if I put 1 "string" only the script works but if I add another "string" it wont work.

       

      If [Table::Field = "string1, string2, string3"
         Insert Text [Select; Table::Field2; "Text1"]
      Else
         Insert Text [Select; Table::Field2; "Text2"]

      Any help will be appreciated, thanks

        • 1. Re: Conditional Multiple String Value
          ralvy

          If ( field1 = "string1" or field1 = "string2" or field1 = "string3" ;

          Insert Text ( field2 ; "text1" ) ;

          Insert Text ( field2 ; "text2" )

          )

           

          Alternatively ...

           

          Let ( x = field1 ;

          If ( x = "string1" or x = "string2" or x = "string3" ;

          Insert Text ( field ; "text1" ) ;

          Insert Text ( field ; "text2" )

          )

          )

          • 2. Re: Conditional Multiple String Value
            philmodjunk

            And Set Field is a better choice than Insert Text. Insert Text only works if the target field is physcially present on your layout. If future changes to your layout remove this field, your script will suddently fail to work and no error messages that it isn't working will be displayed.

            The set field step can even include the If as part of the calculation if you like:

            Set Field [YourTable::YourField ; Let ( x = field 1 ; if ( x = "string1" or x = "String2" or x = "String3" ; "text1" ; "text2" ) ]