Marc Jonkers
Marc Jonkers

Reputation: 506

xpage button to run agent to save document

On an xpage web application the user only has public documents read access. I would like to find a way for the user to be able to save to a form. I guess the most secure way is by dooing this with an agent since I read somwhere that giving write access to public documents isn't secure.

Let's say I have 2 fields : firstname and lastname . Do I bind them to a scoped variable to have acces to them in the agent or is there a better way ?

How do I run the agent on a button click ? is following correct ? var agent:NotesAgent = database.getAgent("(register)");

How do I give the agent the necessary authority to save the document? And how do I get my data in my agent ? with for example sessionScope.firstName or is there a better way ?

Upvotes: 0

Views: 278

Answers (2)

stwissel
stwissel

Reputation: 20384

The eventually smartest way: store that data into another database at all. XPages allows you to write to a different database. If the name shouldn't be visible for other public users, then use depositor as access level

Upvotes: 3

Knut Herrmann
Knut Herrmann

Reputation: 30960

Don't use an agent for saving a document. Use sessionAsSigner instead.

sessionAsSigner allows to run code with the permission of XPage's signer instead of the current user accessing the XPage.

Example:

var db:NotesDatabase = sessionAsSigner.getCurrentDatabase();
var doc:NotesDocument = db.createDocument();
...
doc.save();

Upvotes: 1

Related Questions