0
votes

The ACL of my database has Anonymous set to No Access with Read Public documents set. I have an Xpage that I set to Public Access. The page displays fine, without having to login, with the exception that the page that is supposed to display a message based on a field in a document that is looked up from a view. The lookup fails if public access is turned on for the xPage. If I turn Public Access off for the xPage then I am of course asked to log in to display the page but the message displays on the page.

Here is the formula that I am using. I have modfied it a bit to help troubleshoot this issue. With Public Access for the xPage set, the code displays a "4" (document not found in the view).

var vw:NotesView = database.getView("Setup");
var doc:NotesDocument = vw.getDocumentByKey("Setup",true);
if (doc != null)
{
try
{
    return "1"+doc.getFirstItem("PasswordChangeSuccess").getMIMEEntity().getContentAsText();
}
catch (e)
{   try
    {
        return "2"+doc.getFirstItem("PasswordChangeSuccess").getText();
    }
    catch (e)
    {

        return "3";     
    }

}
}
else return "4";

I have Public Access set for both the Setup view and the form that displays the Setup view. The PasswordChangeSuccess field is a richtext /MIME field.

I also tried placing a $PublicAccess on the form with no luck. Any idea what is wrong?

2
Please verify that the form itself has no acl defined and the data does have the correct values in the reader/authors fieldsjjtbsomhorst
Does your document have a $PublicAccess field?Sven Hasselbach
@jjbsomhorst - Form is set to All Readers and Above. No special Security.Bruce Stemplewski
@Sven - Look at the last line of my post.Bruce Stemplewski
@BruceStemplewski: I have read your last line. You are talking about the form, I was talking about the document stored in your database.Sven Hasselbach

2 Answers

1
votes

e.message gives you the error message, add it to your output. My bet is on lack of access. Try this:

    var vw:NotesView = database.getView("Setup");
    if (vw == null ) {
        print("Failed to get the view");
        return "NULL view encountered";
    }
    print("View is valid");

    var doc:NotesDocument = vw.getDocumentByKey("Setup",true);

   if (doc == null) {
      print("Doc could not be obtained");
      return("Doc could not be obtained");
   }

   // Only here the fun starts!

  try {
       return "1"+doc.getFirstItem("PasswordChangeSuccess").getMIMEEntity().getContentAsText();
  } catch (e) {
    print("MIME failed:" +e.message);
    try {
         return "2"+doc.getFirstItem("PasswordChangeSuccess").getText();
    } catch (e) {
      print(e.message);
      return e.message;     
    }

 }
 // If you got here, what happened?
 return("Miracle");

You also should drop you Java/C formatting preference. In JavaScript line endings have significance. so

 function bla()
 {

 }

gets processed differently from

 function bla() {

 }

at least there's an extra does that line ending require an auto-inserted semicolon processing step. In Java/C it is a matter of coding taste (and up to you). In JavaScript it impacts processing.

0
votes

Figured it out. While the $PublicAccess field was on the form it was not being computed. Everything seems to be working now.