2 Replies Latest reply on Jun 24, 2015 4:33 AM by CCSDVS21

    Combine values separated by " & " only if the second field has a value.

    CCSDVS21

      I'm trying to combine 2 fields and add an & symbol in between, but only if there is text entered in the second field.  This way I wouldn't end up with "Seller Names: Joe Smith &" if there was only one seller name.

       

      Here is my current script, this of course is automatically adding the " & " all the time.

       

      // Get the field values, as strings

      var s1 = getField("s1").valueAsString;

      var s2 = getField("s2").valueAsString;

       

      // Combine values, separated by &

      event.value = s1 + " & " + s2;