Learn how to a build a cloud-first strategyRegister Now


Checking if a Field is NULL!

Posted on 2004-12-01
Medium Priority
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

ID: 12719973
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

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

LVL 31

Accepted Solution

qwaletee earned 2000 total points
ID: 12720333
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

ID: 12723798
all the answers are on target.

Good going..

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 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