Search code examples
xpagesxpages-ssjs

xpages open pages using [NRIC] Field


Question here, may i know using this way to open existing document is totally wrong, or i miss out some part?

Cuz currently not be able to open existing document.

Let say i already have the "document" inside with NRIC 851013-13-5125

Index Submit

Below is the code to get DocumentID

var vw:notesView = database.getView("Request sort by nric used for docID");
var doc:NotesDocument = vw.getDocumentByKey(document1.getValue("NRIC"), true)
if (doc!=null){
    return doc.getItemValue("docID")
}

Solution

  • Desmond,

    beside a HUGE security hole - displaying data based on an NRIC only (which is almost public data, since you use it everywhere to sign up for membership, discount cards etc.

    You should change a few things:

    • Bind you entry box to a scope variable, not a document, so instead of document1.getValue("NRIC") you use viewScope.NRIC
    • You don't need to go after an item, but use doc.universalid, or better have that as a column in the view, so you could use @DbLookup(....)
    • Even better: you could simply redirect the URL to open /yourdb.nsf/byNRIC/[S12345678X] having a view byNRIC that is sorted by NRIC and has in the form property the XPage to open

    Having said that: PLEASE(!!!) implement proper security. Singapore's legislation is VERY specific on data protection. You might want to read up on it here: https://www.pdpc.gov.sg/legislation-and-guidelines/overview