Reader field dilemma

Looking for a solution to my reader field dilemma.

I am creating a document from an existing document in the same database using script in a button in the existing document.

The new document contains a computed reader field.

Once the new document is created the reader field is not computed or set with values nor does it even exist. I tried a ComputeWithForm before I save the new documents in my script, but that does not work.

The only why I can create or set the reader field is to manually do a @Command([ToolsRefreshSelectedDocs]) from the agent in the view.

What is the best way to achieve this?

Subject: Reader field dilemma

If you are already using Lotusscript, you can set the field values directly and make the field a Readers-type field thusly:

Dim readersItem As NotesItem

Set readersItem = doc.ReplaceItemvalue(“Fieldname”, [names array here])

readersItem.IsReaders = True

Note that the names array must be in canonical format to work as expected in all circumstances. (Abbreviated won’t work; Common may appear to work if the user and the server share the same org values in their fully-distinguished names, but it relies on a fragile coincidence.)

Subject: RE: Reader field dilemma

Rich, The script may not be useful to you because the reader fields in question are computed fields in the new documnet based on the values below…

FieldName: DefaultReaders

Type: Reader - Computed

Value: @Trim ( @Subset ( @DbName; 1 ) : “LocalDomainServers” : “[DefaultReaders]” )

FieldName: DocReaders

Type: Readers - Computed

Value: @Trim( Manager_1 : Manager_2 : Manager_3 : Manager_4 : Manager_5 : DivisionHRManager : DepartmentVP : OperationsVP : HumanResourceVP : Accountant : “[AccountingMgr]”)

Manager_1 : Manager_2 : Manager_3 etc. are fields in the form (ie Bob Brindza, Joe Posser, Tony Boots) that are created form the original document in button script .

newDoc.Manager_1 = doc.ManagerName(0)

newDoc.Manager_2 = doc.Manager_2(0)

newDoc.Manager_3 = doc.Manager_3(0)

Stan,

Your suggestion makes sense, however how do I code the names array (“Fieldname”, [names array]) in canonical format if the names I retrieve from the manager name fields are not?

Subject: RE: Reader field dilemma

You’re right. Showing the code might not help. On the other hand, it might. You’re saying that computeWithForm doesn’t work, but refreshing the document does. Since they both should execute the same formula, I think it’s probably something in the code that is responsible for that. E.g., did you remember to set the Form item explicitly before calling ComputeWithForm?

-rich

Subject: RE: Reader field dilemma

Your suggestion makes sense, however how do I code the names array (“Fieldname”, [names array]) in canonical format if the names I retrieve from the manager name fields are not?

You’ll need to do an @dblookup against the NABs hidden $Users view

Subject: Reader field dilemma

Stan is correct, however since you clearly have the expectation that the readernames field should have been created, and it wasn’t… it sounds to me like something else might be wrong with what you’re doing. So show your code, and give more details.

-rich