I have a formula that I need to print with multiple conditions. I'm using a UDF with some codes in MAS that I need Crystal to convert into text.

I have a formula that I need to print with multiple conditions. I'm using a UDF with some codes in MAS that I need Crystal to convert into text. For example in MAS I could have in the UDF 23IJG. So I need Crystal to convert that too.
if UDF_RESTRICT contains 1 then No 3rd Party Sales
if UDF_RESTRICT contains 2 then No Amazon
if UDF_RESTRICT contains 3 then No Ebay
if UDF_RESTRICT contains U then No USA
if UDF_RESTRICT contains J then No Japan
if UDF_RESTRICT contains I then No Italy
if UDF_RESTRICT contains G then No German
if UDF_RESTRICT contains E then No Europe
if UDF_RESTRICT contains X then No Export
So If UDF is 23IJG the text should read = No Amazon, No Ebay, No Italy, No Japan, No German

  • 0
    It would have to be done like the Address block.

    if UDF_RESTRICT contains 1 then First = "No 3rd Party Sales"
    if UDF_RESTRICT contains 2 then Second = "No Amazon"

    Formula = First+second

    the "contains 1" part is not correct of course.
  • 0

    What about using the inStr function to see if the value is in the string, and if the condition is true (not zero) then concatenate the description of that restriction code onto a full description string.

    Maybe something like this:

    fullDescription = ""

    if inStr({UDF_RESTRICT}, "1") then

    fullDescription = fullDescription + " No 3rd Party Sales "

    if inStr({UDF_RESTRICT}, "2") then

    fullDescription = fullDescription + " No Amazon "

    ... and so on, for each restriction code...

    and finally, return fullDescription when through

    formula = fullDescription

    (This leaves out the logic to determine when to insert commas between the code descriptions.)

  • 0 in reply to Dandar

    For the commas, you really just need to worry about the first code description to be concatenated to the full description string. If it is not empty, then you could start each string to be concatenated with a comma and space (e.g. ", No Amazon"); but if it is empty then the code description should not contain a comma.

    So, inserting the following for each conditional might work:

    if inStr({UDF_RESTRICT}, "1") then

    if fullDescription = "" then

    fullDescription = fullDescription + "No 3rd Party Sales"

    else

    fullDescription = fullDescription + ", No 3rd Party Sales"

  • 0 in reply to BigLouie
    Thanks, that works great!