0
db = new Array("myserver", "myfolder\\mydb.nsf") 
dir = getComponent("Dir").value; 
div = getComponent("Div").value; 
lu = @DbLookup(db, "ManagerAccess", dir + "PP" + div, "DTManagers"); 
var a = []; 
a.push(lu); 
var item:NotesItem = docBackEnd.replaceItemValue('FormReaders', @Unique(a)); 
item.setReaders(true);

That code is on the querySaveDocument ssjs. The result I get from the @DbLookup (when I put in a computed field) look like this: Pedro Martinez,Manny Ramirez,David Ortiz,Terry Francona

I tried doing an @Explode(@Implode) thing on it, but it doesn't seem to work. The error I get in the browser just tells me that the replaceItemValue line is broken. To test it, I pushed several strings one at a time, and it worked correctly populating my FormReaders field with the multiple entries.

What am I doing wrong?

Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29
m benway
  • 245
  • 2
  • 10

1 Answers1

1

I see several problems here:

A. In cases as described by you @Dblookup in fact would return an array. If you push an array into a plain computedField control it will exactly look as that you wrote:

value1, value2, ..., valueN

A computedField doesn't know anything about multiple values etc, it just can display strings, or data that can be converted to strings.

If you want to test the return value you could try to return something like lu[0]; you then should receive the array's 1st element, or a runtime error, if lu is NOT an array. Or you could ask for the array's size using lu.length. That returns the number of array elements, or the number of characters if it's just a plain string.

B. your code contains these two lines:

var a = [];
a.push(lu);

By that you create an empty array, then push lu[] to the first element of a[]. The result is something like this:

a[0] = [value1, value2, ..., valueN],

i.e. a is an array where the first element contains another array. Since you don't want that, just use @Unique(lu) in your replaceItemValue-method.

C. I don't see why replaceItemValue would throw an error here, apart from what I wrote in topic B. Give it a try by writing lu directly to the item (first without @Unique). That should work.

D. for completeness: in the first line you used "new Array". A much better way to define your db parameters is

var db = ["myserver", "myfolder/mydb.nsf"];

(see Tim Tripcony's comment in your recent question, or see his blog entry at http://www.timtripcony.com/blog.nsf/d6plinks/TTRY-9AN5ZK)

Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29
  • A. I writing to editable Readers field name FormReaders. I only mentioned a computed field to demonstrate that I had tested the lookup and that it found the desired results. D. Thank you. I keep doing that! – m benway Jan 15 '14 at 15:26
  • Yes, I got it like that; I guess most of us are using computedFields for quick debugging tasks. What I wanted to say is that what you get in your debugging field is quite correct. - question is: is your replaceItemValue working when directly passing "lu"? – Lothar Mueller Jan 15 '14 at 15:41