0

I have an ordering system in xPages. In the main order form I accept the customer information as document1 and save those fields as fOrderForm (Form). On the same page I have a view control with all the items ordered which are stored as separate documents than the Customer data. I can save these as new documents with no issues. When I go to open one of the orders which would need code to set a viewScope variable to the order number so the view control can display the order items, it gives me the following error. I have Anonymous set at Editor. I'm new to xPages. Can someone shed some light?

com.ibm.xsp.FacesExceptionEx: Could not open the document
    com.ibm.xsp.model.domino.DominoDocumentData.doOpenDocument(Unknown Source)
    com.ibm.xsp.model.AbstractDocumentDataSource.openDocument(Unknown Source)
    com.ibm.xsp.model.AbstractDocumentDataSource.load(Unknown Source)
    com.ibm.xsp.model.AbstractDataSource.getDataContainer(Unknown Source)
    com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(Unknown Source)
    com.ibm.xsp.model.AbstractDataSource.pushData(Unknown Source)
    com.ibm.xsp.util.DataPublisher.publishControlData(Unknown Source)
    com.ibm.xsp.component.UIViewRootEx.publishControlData(Unknown Source)
    com.ibm.xsp.component.UIViewRootEx.initBeforeContents(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(Unknown Source)
    com.ibm.xsp.application.ViewHandlerEx.createView(Unknown Source)
    com.ibm.xsp.webapp.FacesServlet.serviceView(Unknown Source)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(Unknown Source)
    com.ibm.xsp.webapp.FacesServlet.service(Unknown Source)
    com.ibm.xsp.webapp.FacesServletEx.service(Unknown Source)
    com.ibm.xsp.webapp.DesignerFacesServlet.service(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService.access$0(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
    java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    java.util.concurrent.FutureTask.run(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    java.lang.Thread.run(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceThread.run(Unknown Source)
NotesException: Invalid universal id
    lotus.domino.local.Database.NgetDocumentByUNID(Native Method)
    lotus.domino.local.Database.getDocumentByUNID(Unknown Source)
    com.ibm.xsp.model.domino.DominoUtils.getDocumentById(Unknown Source)
    com.ibm.xsp.model.domino.DominoUtils.getDocumentById(Unknown Source)
    com.ibm.xsp.model.domino.DominoDocumentData.doOpenDocument(Unknown Source)
    com.ibm.xsp.model.AbstractDocumentDataSource.openDocument(Unknown Source)
    com.ibm.xsp.model.AbstractDocumentDataSource.load(Unknown Source)
    com.ibm.xsp.model.AbstractDataSource.getDataContainer(Unknown Source)
    com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(Unknown Source)
    com.ibm.xsp.model.AbstractDataSource.pushData(Unknown Source)
    com.ibm.xsp.util.DataPublisher.publishControlData(Unknown Source)
    com.ibm.xsp.component.UIViewRootEx.publishControlData(Unknown Source)
    com.ibm.xsp.component.UIViewRootEx.initBeforeContents(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(Unknown Source)
    com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(Unknown Source)
    com.ibm.xsp.application.ViewHandlerEx.createView(Unknown Source)
    com.ibm.xsp.webapp.FacesServlet.serviceView(Unknown Source)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(Unknown Source)
    com.ibm.xsp.webapp.FacesServlet.service(Unknown Source)
    com.ibm.xsp.webapp.FacesServletEx.service(Unknown Source)
    com.ibm.xsp.webapp.DesignerFacesServlet.service(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(Unknown Source)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService.access$0(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
    java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    java.util.concurrent.FutureTask.run(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    java.lang.Thread.run(Unknown Source)
    com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceThread.run(Unknown Source)
  • as I see in the stacktrace you are trying to open the document with an invalid Id. Can you show how you open the page, with which url? – Frank van der Linden Mar 15 '16 at 14:24
  • http://localhost/SalesOrders.nsf/%24%24OpenDominoDocument.xsp?documentId=88B821586056495485257F72006A1783&action=editDocument This is what the link from the view is. – Mike Gonzalez Mar 15 '16 at 17:51
  • 1
    The url wants to open the $$OpenDominoDocument. That is a default action in a view panel. To make it work there should be a xpage with the same name of the form who is trying to be opened. Or an XPage set as default to be opened in the database properties. See http://stackoverflow.com/questions/29164009/error-accessing-xpage-using-opendominodocument-xsp-method-on-database-replica – Frank van der Linden Mar 15 '16 at 19:41
  • I do have a form named what the document has for Form. In that form, I also tell the system to open the xpage for the order. – Mike Gonzalez Mar 17 '16 at 16:36

1 Answers1

1

viewScope variables can't be used in some dominoDocument datasource properties, for example documentId, if it's attached to the XPage or Custom Control. I covered this in my recent session at IBM Connect and I'll be covering it again at Engage next week.

Move it to a Panel and you'll be fine.

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
  • I have all the fields on the form within panels. – Mike Gonzalez Mar 15 '16 at 17:52
  • 1
    No, the data source is what's key, not the fields. The field properties will be processed after viewScope is created, but the data source will be processed before viewScope is created if bound to the XPage (the createView method in the stack trace). If the data source is added to a panel instead all properties can be processed during page load event instead. – Paul Stephen Withers Mar 15 '16 at 18:39
  • I'm not completely understanding of binding and data sources. They might be very simple but..... I have document1 defined as fOrderForm. I have docLineItem defined as fOrderLineItem. In addition I have 24 views as data sources that are used on this form in one way or another. The Dojo Data Grid is filtered by a viewScope vsOrderUNID which is common to the customer and line item documents. I assume that in the beforePageLoad event, I have to recognize that document1 is not a new doc and load all the variables for document1 plus the UNID viewScope variable for the data grid, is that right? – Mike Gonzalez Mar 17 '16 at 13:04
  • datasources can be attached to an XPage, Custom Control or Panel. If attached to an XPage (probably also Custom Control),properties like `documentId` are set **before** beforePageLoad runs and before viewScope exists. So you will get an error when trying to use viewScope. If attached to a Panel, the properties can be computed **after** beforePageLoad and after viewScope has been created. A print() statement in SSJS in beforePageLoad will help troubleshoot order of processing. With the stack trace in your question, the print statement will not run, before the error is **before** beforePageLoad. – Paul Stephen Withers Mar 17 '16 at 21:29
  • 1
    I've blogged in more detail on this http://www.intec.co.uk/datasources-and-viewscope/. Basically, add the datasource directly onto the XPage level and you can use viewScope variables. – Paul Stephen Withers Mar 31 '16 at 12:49