In a web application, I have a form with an editable multi-valued field. The field is defined to separate and display values with a ‘new line’. However, I find that if a null value is entered on a new line, it is not saved. For example …
The following text list is entered:
one
two
The following text list is saved:
one
two
Is there a means of saving a null value in a text list that’s entered into an editable field?
One of the major pains in the back side with the way Notes handles arrays. You can not have a null value. This really makes it difficult when trying to have two or more arrays associated, but not all of the values have been filled in yet. The way we get around this is by defining a null state. For example if the array is an array of dates we take an arbitrary but know date (we have used Jan 1 1960 but that may not work in all situations if that date might be a valid entry) then put an output conversion on the field that converts that single date to a “-” in the output. In a text string we insert a “-”. A numeric field is a bit tougher because Zero might be a valid entry. If the value will always be positive use a negative number.
The solution is really “kludgy” but it ‘works’, not well but it works. I wish we could assign a placeholder in an array that would say “some time in the future a value will be assigned, but just not right now.” and that this placeholder would not cause the various displays of Dates, Numbers etc to crash. For example you can not put a “-” in a date or number field without problems. So if a placeholder character was a say Char(255) the display engine would know that that was a null value in an array and handle it logically.
I realize that I probably have not really answered your question but this is a major beef that I have with the way Notes handles (Not) Null values in an array.
Subject: RE: the correct question is : “why do you have null values ?” merry christmas
Your response is flipant and assumes that you know everything. We have many instants where we need null values in an array. Your assumption that you should never need them is hard to understand.If you have ever tried to set up three arrays of information that need to be associated will soon present you with the problem of how to hold a null value. If you have three arrays lets call them Name, RecievedDate, ActionDate now set the Names field to 10 different names. Now the person Name(3) acknowledges reciept so you want to set RecievedDate(3) = Today, but Name(0), Name(1) and Name(2) have not acknowledged reciept would it not ne a nice feature to be able to initialize the Array RecieveDate to contain 10 null place holders and could set RecieveDate(3) to a value even if 0,1, &2 had not responded?
A response to the above forum entry suggests that simply defining the field to separate and display values using the ‘New Line’ separator would include nulls. I found that this is not the case - even with the ‘New Line’ separator, nulls are not saved in a text list.
Apparently there is not a means of checking programmatically whether nulls exist in a text list. (This is a web application and the NotesUIDocument class is not available.) For example, neither of the following two coding options in a WebQuerySave agent can identify whether nulls are included in a text list.
OPTION 1:
Dim fieldNameVar As Variant
Dim x As Integer
fieldNameVar = note.GetItemValue(“fieldName”)
x = 0
Forall a In fieldNameVar
Msgbox("a has a value of " & a)
x = x + 1
End Forall
OPTION 2:
Dim item As NotesItem
Set item = note.GetFirstItem( “fieldName” )
Forall v In item.Values
Msgbox( "v has a value of " & v )
End Forall
If nulls could be identified, they could be converted to non-null values in a WebQuerySave agent and then converted back to a nulls in a WebQueryOpen agent.
Unfortunately if you call support you’ll get the dreaded “Notes is working as designed” response. It removes empty entries from lists and that’s just how it works. The only way I have ever gotten empty values into a multivalue field is like this:
Dim myarray(3) As String
myarray(0) = “bob”
myarray(1) = “”
myarray(2) = “carol”
Call doc.ReplaceItemValue(“list”, myarray)
That will correctly store the blank entries. Now the question is how do you allow users to enter the blank values in the first place, then copy them to the backend document. I don’t have an answer for that, unfortunately. :-\
I’ll check the app I have at work that uses this technique tomorrow and jog my memory on what I was trying to accomplish. I remember doing it, mostly because it took me forever to find a workable solution, I just don’t remember why.