Search code examples
viewxpagesxpages-ssjs

How do I get documents from view based on 2 keys


I have an XPage where I find all children documents using view through key(first column) with method called getAllDocumentsByKey method. As a key I use UNID of a parent. But now I have another parameter called ChildType which can either be equal 'Before' or 'After'. So I've tried to solve it like this:

var childType = viewScope['currentChildType']
var parameters = [parentDoc.getUniversalID(), childType]
allParts.getAllDocumentsByKey(parameters)

But it doesn't work(Vector is not a correct object). When I try to find all children with this:

allParts.getAllDocumentsByKey(parentDoc.getUniversalID())

It works so well.

My view has 5 columns - 0th is parentDocID and the last one is childType. How can I make it find with 2 params, instead of 1?


Solution

  • You are creating an array but the method getAllDocumentsByKey() expects a Vector

    var parameters  = new java.util.Vector();
    parameters.add(parentDoc.getUniversalID());
    parameters.add(childType);
    allParts.getAllDocumentsByKey(parameters);
    

    See also: https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/reference/r_domino_View_getAllDocumentsByKey.html