Forum Discussion

ElizabethSchlag's avatar
ElizabethSchlag
Qrew Trainee
9 months ago

New Form Field Error - There are extra characters beyond the end of the formula

I am trying to create a rich text field to put in the form that shows what the current value is in another field. This doesn't work directly in the new form. Instead, I am building a formula rich text field that I will then add to the field. I am getting an error that I'm not sure how to get around: There are extra characters beyond the end of the formula. Thoughts?

"Current State is" ToText([state])". Current Target Completion Date is" [target completion date]"."



------------------------------
Elizabeth Schlagel
------------------------------

4 Replies

  • Since you're combining strings you need to put & between the different components so QB knows to combine them properly. 

    See below: 

    "Current State is" & ToText([state]) & ". Current Target Completion Date is" & [target completion date] & "."



    ------------------------------
    Chayce Duncan
    ------------------------------
    • ElizabethSchlag's avatar
      ElizabethSchlag
      Qrew Trainee

      Awesome, thank you!! Do you know if it's possible to put an if statement in there to show  [state] in red, yellow, or green font depending on what the state says? Similar to this, but something that actually works:|

      "Current State is " & 
      If((ToText([State])="red"), <span style="color:red">[state]</span>, If((ToText([State])="yellow"), <span style="color:yellow">[state]</span>, <span style="color:green">[state]</span>  &
      ". Current Target Completion Date is " & [Target Completion Date] & "."



      ------------------------------
      Elizabeth Schlagel
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        You're close - since you're inserting tags with inline style you have to be careful with using " versus ' since the html needs one or the other while Quickbase still needs to make sure it can read the entire thing as one long string. Modify it as follows (take note that I refactored your if to be a little cleaner since it was a little hard to read with multiple if statements)

        "Current State is " &  
        If(

             ToText([State])="red", "<span style='color:red'>",

             ToText([State])="yellow", "<span style='color:yellow'>",

             ToText([State])="green", "<span style='color:green'>",

        "<span>") & [state] & "</span>"  &
        ". Current Target Completion Date is " & [Target Completion Date] & "."

        Notice in the above that the inline style for your colors are in ' as opposed to having ". This makes it a little more readable in my opinion.



        ------------------------------
        Chayce Duncan
        ------------------------------