5 Replies Latest reply on Feb 7, 2014 11:36 AM by Matt Lutton

    Bad Character error in calculated field

    jonathan.richman.2

      I have a calculated field that's like this (but with a bunch more lines):

       

      if [name]="Cheesesteak" then "Item 83"

      elseif [name]="Mac & Cheese" then "Item 84"

      elseif [name]="Spaghetti & Meatballs" then "Item 84"

      End

       

      I'm getting a bad character error due to the "&". I've tried escaping it like so: else if [name]="Mac \& Cheese" then "Item 84" but that doesn't work.

       

      I noticed that if I switch to single quotes around the lines that have the & the bad character warning goes away, but then at the end I get an unterminated string error.

       

      Like this:

       

      if [name]="Cheesesteak" then "Item 83"

      elseif [name]='Mac & Cheese' then "Item 84"

      elseif [name]='Spaghetti & Meatballs' then "Item 84"

      End

       

      I've tried making all quotes single and all quote double and I think every combination in between, but I end up with either bad character errors or unterminated strings.

       

      What I'm trying to do is take every product name and de-identify it be changing it to an Item number. It works for everything but those items with an &. The problem is that I can't just leave those in and not change them.

       

      Any advice would be appreciated.


      Thanks,

      JR