You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Feature Request: MultiValue Field object[] returns a length of 1 even if there are no values in the object array. Should return zero.

SDK
posted on May 20, 2015

The current LFSDK COM versions return an object array when asking for values from a multi-valued field.

In the past, this object used to return a length of zero if there were no actual data in any of the items in the array.

It now returns 1 as the array length, but when you try to access array object [0] (in C#), it is actually a NULL. 

This is deceptive.  I suggest that if there is NO data in the multi-valued field, querying the array length should return zero, not one.

Many of the applications I have written worked fine in the past, but had to be modified to ignore the fact that the SDK is "lying" that there is a value in the collection, when there is actually none.

 

As in:

entryFieldData = (LFFieldData) entryDoc.FieldData;

object[] objMultiVals = (object[]) entryFieldData.get_Field(tokenMultiValueFieldName);

if (objMultiVals.Length != 0) 

{

  // Process values here  -- Fails if you try to access objMultiVals[0] -- because it is null.

}

 

 

0 0
replied on May 20, 2015

This quirk goes back a long way, I tried this out and empty multivalue fields return a 1-element array as far back as SDK 8.0 and LF server 8.1. At this point changing it seems like too big of a regression risk. The .NET SDK does what you would expect, no value returns null, a single value returns that value, and multiple values returns an array.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.