Checking for Nulls in Custom Functions

I am attempting to write a custom function in Crystal that checks to see if a string is null.  If it is null, it returns "" (empty string).  If it is not null, it returns the original string.  Unfortunately,  using IsNull results in "This function cannot be used within a custom function."  How can I check for Null in a Custom Function?

My current code is

Function (stringVar strCurrent)
If isnull(strCurrent) then "" else strCurrent

Thanks!
pmetechAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
It would be nice, but it appears that isn't a test you can do in a custom formula.

mlmcc
0
 
mlmccCommented:
You may not be able to.

Try this.

If (StrCurrent = '') then
    ''
else
    StrCurrent

If that doesn't work try
If Length(StrCurrent) = 0 then
    ''
else
    StrCurrnet

mlmcc
0
 
pmetechAuthor Commented:
Sorry, neither one worked.
0
 
mlmccCommented:
I just tried to create one and couldn't figure out how to test for NULL.

How are you planning to use this?

Can you write a Crystal formula to do it?

mlmcc
0
 
pmetechAuthor Commented:
I have a number of strings that I'm concatenating into one long string.  Currently, I'm using "List of Values: " & (If isnull(Value1) then "" else Value1) & ", " (If isnull(Value2) then "" else Value2) & ", " (If isnull(Value3) then "" else Value3) & ", " (If isnull(Value4) then "" else Value4).  I would like to replace each if statement with a custom formula.
0
All Courses

From novice to tech pro — start learning today.