# 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!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
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
Author Commented:
Sorry, neither one worked.
0
Commented:
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
Author 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
Commented:
It would be nice, but it appears that isn't a test you can do in a custom formula.

mlmcc
0

Experts Exchange Solution brought to you by