How do I append a value to results of @DBlookup in xpages?
-
10-06-2021 - |
سؤال
How do I append a value to results of @DBlookup in xpages?
I tried this but it does not seem to work.
var v = @DbLookup("","Setup","Setup","ModRationales").push("Other 2"); return v;
It shows 6.0 in my listbox.
المحلول 2
Got it:
var v = @DbLookup("","Setup","Setup","ModRationales");
v.push("Other");
return v;
نصائح أخرى
First of all: @DbLookup returns a string when it looks up one value only, and it returns an array when it finds multiple values. I will therefore suggest that you use the DbLookupArray() function available as a xsnippet as this function always returns an array. It has other advantages too such as optional caching of the result.
Then it is just a matter of adding elements to the array using .push() on the result returned by DbLookupArray().
Your current lookup is most likely returning a single element - which in the case of @DbLookup is a string.