Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xPages creating Authors and Readers Fields

Tags:

xpages

I have a querySaveDocument function for my xPage where I set up some backend fields, including Authors and Readers fields.

var authors = new Array("[AdminEditors]");
var user:String=session.getEffectiveUserName();
authors.push( user );
var authitem:NotesItem = doc.replaceItemValue("z_Authors", authors );
authitem.setAuthors(true);

var readitem:NotesItem = doc.replaceItemValue("z_Readers", "[AdminReaders]" );
readitem.setReaders(true);

I thought doc.replaceItemValue() would return a reference to the NotesItem, but authItem is null.

So how does one create a field on the backend Notes Document using SSJS and get a reference to it?

Thanks,

-- Jeff

like image 766
Jeff Byrd Avatar asked Apr 25 '12 00:04

Jeff Byrd


1 Answers

Make sure to use getDocument(true) to have the backend document synced with changes made in the frontend document.

var doc = document1.getDocument(true);
like image 104
Per Henrik Lausten Avatar answered Sep 25 '22 15:09

Per Henrik Lausten