Checking if a Field is NULL!

Posted on 2004-12-01
Last Modified: 2013-12-18
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!
Question by:ozone7
    LVL 15

    Expert Comment

    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
    end if

    ' no field - ok !

    end if

    sub doOK()
    ' code to execute
    end sub
    LVL 14

    Expert Comment

    if doc.<yourfieldname>(0) ="" then
    msgbox "it's empty"
    end if

    LVL 31

    Accepted Solution

    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 = "")
            IsFieldNull = True
        End If
    End Function
    LVL 19

    Expert Comment

    all the answers are on target.

    Good going..

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
    Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now