When performing a javascript serverside @dbcolumn lookup in Xpages the return type seems to vary based upon the number of results.eg
var Level1Unid = @DbColumn(“” , MenuName ,3)
will return a variable of type array if there is more than 1 document in the MenuName view, but if there’s only one document the return value is of type string…
Anyone else seen this? I’ve currently had to test the type (typeof) and if it’s a string copied it into an array at index 0 to ensure consistency…
Ian
Subject: Thanks everyone
Thanks for the responses - I’ll go with Johns suggestion of using @explode!The snag I hit was getting the array count with .length gave me the string length when there was only one result…
This is my first Xpage but I’m really liking it. Having used .Net for some years, merging that and my Notes developer experience is quite fun!
Subject: Yes this sounds familiar…
… And I think it’s working as designed.
Subject: Working as expected
Yes this is working as expected.
If there is only 1 value to be returned, it will return that object as-is (string, number, datetime, etc).
If there is more than 1 value to be returned, it returns an array containing the values.
Subject: Yes
This changed with the gold release. If multiple results are returned from an @DbLookup or @DbColumn, an array is returned. If a single result is returned the result is the type, such as “string”.
My solution is to use an @Explode on the result, especially for a repeat control iteration formula. This way I am always returning an array.
-John