xPages: Readers and Authors

During my journey through xPages I have now arrived at the access-station!I want to add an Authors-field to the document created through an xPage including the logged in user and a [role].

If I bind to an authors-field it is added as plain text.

I have looked at the data\acl-property on the xPage, but can’t find any documentation on how it works and how to implement.

Any suggestions?

PS! The purpose is to later restrict the user to se only his/her documents with real security.

Subject: My solution with server side JS

I put following code to QuerySaveDocument event of my data source (xpage - events - data):

var authors = new Array(“[Admin]”,“[Manager]”);

var doc:NotesDocument = myDataSource.getDocument(true)

var item:NotesItem = doc.replaceItemValue(“my_authors_field”, authors);

item.setAuthors(true);

myDataSource.replaceItemValue(“my_authors_field”,item);

myDataSource.save();

where

myDataSource is the data source name of my XPage,

my_authors_field is the name of the authors field

Subject: You can also use computeWithForm property

I have had good results using the computeWithForm property which is not a perfect solution but it does work.

Subject: Looking into this to see if I can dig something up.

Was there anythibg in the Wiki?

Subject: Thanks - hope you find something

If it is something in the wiki it is well hidden. I’ve searched there but have not found anything which address this issue…

I also dig on my own. Let you know if I find something…

Subject: I can’t find anything right now so here’s what I got on the on the ‘acl’ property…

The acl property in the XPages provides another layer of security at document level. The user will still have to go through the other security layers, server access, Application ACL, before they get to this level.

It’s a property just available on a couple of container controls - Panel, Include Page - and on the XPage itself.

So where to start adding this layer of security?

On a XPage, or Panel or Include Page container control, go to the Properties view, then the All Properties tab and then under the data section select the plus button on the ‘acl’ edit area.

Selecting this adds another property ‘entries’.

From here select the plus button on entries and this will give you your first aclEntry property.

From here it’s a matter of filling out these fields

fullName

Use to define the full name of the entry

name

This is a required field, defines the name of the entry

right

Defines the rights the entry can have which can be NOACCESS, READER or EDITOR.

type

This defines the type of entry. Valid selections are USER, GROUP, ROLE, ORGUNIT, ORGROLE, DEFAULT and ANONYMOUS

And here’s some examples…

Here the user Simon Ligo will have no access…

And here only members of the group will be allowed to edit the contents

Hope this helps.

regards,

Paul.

Subject: Another solution!

Thank you very much for your reply…

During a process of building a test-application to explore your findings I stumbled across this:

http://www.lotusnotebook.com/lotusnotebook.nsf/d6plinks/DLEY-7RH2B2

I used his tip to ‘compute with form’ = ‘onload’

(found on ‘xPage\All Properties’-‘data\data\dominoDocument’)

In addition I had to place an Authors- and Readers field (computed when composed) on my form with this formula:

@UserName

Finally I had to drop these fields on my xPage. In a standard View-control a user will only see the documents he has created. I can also verify this by watching the doc-properties through Notes.

:slight_smile:

Subject: I solved it with a postSave-document

Hi,

Maybe this solution might help you:

Simply launch after every save of your document an agent and pass the note-id of your document:

postSaveDocument-Event in your xPage data connection:

var noteID = Doc.getNoteID();

database.getAgent(“Agent-WebQuerySave”).run(noteID);

Then in your LotusScript Agent write a code which updates/creates your Readers/Authors fields as you like:

Dim Session As New NotesSession

Dim DB As NotesDatabase

Dim Agent As NotesAgent

Dim Doc As NotesDocument	



Set DB = Session.CurrentDatabase

Set Agent = Session.CurrentAgent



If Agent.ParameterDocID <> ""  Then

	Set Doc = DB.GetDocumentByID(Agent.ParameterDocID)

	

	If Not Doc Is Nothing Then