3

I'm trying to get a value from a profile document in the beforePageLoad event of my XPage. To do this I use Server Side Javascript:

var currdb:NotesDatabase = database;
var profdoc:NotesDocument = currdb.getProfileDocument("frmProfile","");
var showRefInfo = profdoc.getItemValueString("ShowReferenceInformation");
sessionScope.put("showRefInfo",@Text(showRefInfo));

The field "ShowReferenceInformation" can have a value of either 1 or 0. I have changed this value from 0 to 1, however my SSJS code continues to return 0. What could be causing this?

4 Answers4

9

Profile docs on the web have always been excessively cached, and I believe this is still the case with XPages. Most likely, what you'll see is that some requests will get the new value while others won't until the cache is fully refreshed after some arbitrary amount of time.

Jesse Gallagher
  • 4,461
  • 13
  • 11
  • Thanks, this is what's happening. I checked again today and the correct value was returned for the same code. –  May 16 '14 at 13:09
  • I've gone two routes to work around it. Similar to others, I've usually switched to having a view keyed by user and just doing normal lookups. In newer cases, I've gone the route used by the OpenNTF API's "Database#getDocumentByKey" to make a doc with a UNID as a hash of the key. That second one is best when you're doing that in a new app that's heavily key-based otherwise, though. In a normal case, the view-lookup route is fast enough. – Jesse Gallagher May 16 '14 at 13:29
3

I actually like profile documents. However the way to use them is in a synchronized function that checks for an ApplicationScope variable and reads that one. If it is not there load from the profile. Write back immediately. So you super cache it.

stwissel
  • 20,110
  • 6
  • 54
  • 101
2

To agree with the previous 2 answers. Do not use profile documents in xpages. The cache is refreshed when the HTTP task is refreshed. This is unacceptable in most environments. I would use another method like applicationScope to set those values.

But if you are ok with having to restart HTTP everytime this entry changes then go ahead and use profile docs in xPages...

Patrick Sawyer
  • 1,362
  • 7
  • 22
1

I agree with Jesse. Caching is usually a big problem with with profile document. When we switched from Notes to XPage Environment we always had the same problem.

The solution is that you could create an simple agent for creating profile documents and then create a view to handle the same.

Chintan Parekh
  • 1,101
  • 1
  • 12
  • 31