Checking if a Field is NULL!

I have a Script that I wan to check and see if a certain field is NULL, if it is not NULL I am going to write/print several fields from a Doc to a text file. If this one Field is NULL, I do not want to print/write, just go on to the next field I am checking ..

I am not sure if I use the ISNULL or doc.field=NUL. I am having problems getting anything to work..

Rookie Here! Help!
ozone7Asked:
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.

Bozzie4IT ArchitectCommented:
First, check if the (notes)item exists.  Then, if it exists, you can check for the empty string with a conversion to text (there are other possibilities)

if doc.hasitem( "YourField" ) then
if doc.getfirstitem("YourField").text = "" then
' empty string ! ok !  This works for numbers, dates, strings, that are empty OR null
doOK()
end if

else
' no field - ok !

doOK()
end if

sub doOK()
' code to execute
end sub
0
p_parthaCommented:
if doc.<yourfieldname>(0) ="" then
msgbox "it's empty"
end if

Partha
0
qwaleteeCommented:
Notes does not have a concept of NULL for its fields.  The closest it comes is you can tell whether a field exists or not, and a non-existant field is generally equivalent to a null string.  In most cases, you won't find fields to be nonexistant at all, since that only occurs in special programming circumstances.

Within a form, fields generally don't have NULL values at all -- only blank value can exist.

So, I would just go with doc.Fieldname(0) = ""

the exception would be rich text fields, which are jut about impossible to check for empyiness.  The nest you can do, usually, is check the .Text value of them, and see if it is a blank string, which could be a bad test if the field contains just an embedded Excel file or a botmap image.

In addition, you can't check a rich text field for emptiness while the documentis being edited, since changes to the rich text field are not norally exposed until the document is closed.

That said, this code could chck either rich text or plain text:

Function IsFieldNull( doc As NotesDocument , fieldName As String) As Integer
    If doc.HasItem(fieldName)
        IsFieldNull = (doc.getFirstItem(fieldName).Text = "")
    Else
        IsFieldNull = True
    End If
End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
madheeswarCommented:
all the answers are on target.

Good going..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.