XPages, Data, DominoDocument from a different database & access

I have an XPage which includes data from two documents in a second database. The XPage is accessed as Anonymous. The source code is below:

<xp:this.data>

	<xp:dominoDocument var="linkDoc"

		databaseName="#{javascript:applicationScope.surveyDbPath}"

		documentId="#{javascript:sessionScope.linkId}" formName="frmLink" 

		action="openDocument"/>

	<xp:dominoDocument var="survDoc"

		databaseName="#{javascript:applicationScope.surveyDbPath}"

		formName="frmSurvey" documentId="#{javascript:sessionScope.survId}"

		action="openDocument">

	</xp:dominoDocument>

</xp:this.data>

As you can see, the actions on both document are only to open. I am not trying to edit the documents, not trying to create anything.

However, for the second database I am pulling the documents from, for some reason I need to give Anonymous Author access with Create Documents privilege. As soon as I untick Create Documents privilege, I am prompted to log in. As soon as I take the data code out, it works fine, even though I have code running beforePageLoad that pulls some information from the particular documents in the second database.

I am confused why I need to give Create Documents privelege, when the code is opening the document, not creating anything in the second database. Is something happening behind the scenes that is creating something in the second database? Is this related to why you cannot have a XPage creating a document based on a public access form?

I really need to give anonymous no higher than Reader access to this source database, which was the reason for trying to use a different database. I have been able to pull information from documents in the second database if I give Anonymous reader access, but as soon as I try to define a datasource for a document, I am prompted to log in.

Any help will be very much appreciated.

Thanks

Paul Withers

Subject: Found answer

sessionScope.linkId and sessionScope.surveyId were being set by code in the beforePageLoad event.

After a bit of trial and error I found these were not getting set before the data was being loaded, so the IDs being passed across were blank.

I’ve got it working by directing to an intermediate page that loads the session variables and, on success, redirects to a page that has the data documents defined.

I found that “context” is not available in the beforePageLoads. Looks like I also have some way to go to understand exactly when the various events are fired.

Subject: Debugging Variables

Declan put a neat control on his website that will let you see the value of any scoped variables.

Subject: Debugging scoped variables

Yes, I would also recommend it highly for anyone developing on XPages. I find it very useful with a visibility formula to ensure it’s visible for developers, so I can always see the settings. Unfortunately in this case I did not get that far!