Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > Server JavaScript > Work with documents and fields on the XPage
xpageswiki.com
is maintained by 
Julian Buss.
You can hire me.

Work with documents and fields on the XPage

ShowTable of Contents

Get and set a field on the XPage

Server JS

getComponent("elementName").getValue();
getComponent("elementName").setValue("something");


Note: you cannot access or set fields with visible=false. If you want to work with a field, but don't want to display it, give the field a CSS class with "display:none".

Get submitted value before validation


getComponent("elementName").getSubmittedValue()

Client JS


document.getElementbyId("#{id:elementID}").value;

Access backend Notes document


Fields on the XPage are bound to a datasource. If the datasource represents a Notes document, you can access that with:

var doc:NotesDocument = datasourcename.getDocument();


Note: the variable "doc" is typed with "NotesDocument" here so that the IDE can give us a help for properties and methods.

To work with a field, you can use

var doc:NotesDocument = datasourcename.getDocument();
doc.replaceItemValue("somefield", "somevalue");


Or to get a field which is in the backend doc but not on the XPage:

var v = datasourcename.getValue("fieldname");

Work with a document in the click event of a submit button


You can access the document and set fields as described above in the onClick event of a submit button.
But you have to redirect to another XPage after that by yourself using context.redirect() then.

Run a agent on document save


Something like the "WebQuerySave" agent in classic domino development. In datasource -> querySave event run

var agent:NotesAgent=database.getAgent("agentname");
agent.run(datasourcename.getDocument().getNoteID());
Im Agent bekommt man das Dokument dann via notesDatabase.GetDocumentByID( NotesAgent.ParameterDocID )


In the agent you get the noteID of the saved document with

set session = new notesSession
set database = session.currentDatabase
set agent = session.currentAgent
set doc = database.getDocumentByID(agent.parameterDocID);
How to take your XPages App to the iPhone, iPad, Android: use Domino To Go!
Do you look for an XPages Workflow solution? Take YouAtNotes Workflow.