2
votes

When we declare a dominoDocument as an XPages datasource, we can specify the documentid programmaticaly. However, I've not found a way to trap the error if the specfied id does not exist. I get an error 500 / Could not open document error on the log.

I would expext to get a null "document1" or something but be able to catch error nicely.

<xp:this.data>
<xp:dominoDocument var="document1" action="openDocument" documentId="some noteId here" formName="Document" ignoreRequestParams="true">
<xp:this.databaseName>...</xp:this.databaseName>
</xp:dominoDocument>
</xp:this.data>

Any hint ?

thanks

1
Just an idea, you can try using queryOpenDocument to check if Document exists and perhaps compute another value for documentId propertyEgor Margineanu

1 Answers

4
votes

You can put the error handling in your code for calculating the documentid.

<xp:this.documentId><![CDATA[#{javascript: 
    var id = "your calculated id";
    try {
        database.getDocumentByUNID(id);
    } catch(e) {
        context.redirectToPage("pageError", true);
    }
    return id}]]>
</xp:this.documentId>

Like in example above you can open e.g. an error page.