GetListItemsConfig data source not accessible - InfoPath Dev
in

InfoPath Dev

GetListItemsConfig data source not accessible

Last post 08-03-2006 04:35 PM by Greg Collins. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-02-2006 03:56 PM

    GetListItemsConfig data source not accessible

    Following the How-To "Query for Items in SharePoint Form Library Using GetListItems Web Method" I am coming across a null reference exception when trying to access the GetListItemsConfig data source in the getListItems method of the example. I have altered the example slightly by having a dropdown box instead of a text box. Basically it works fine with the initial selection from the dropdown but when I try to select a new item from the dropdown it somehow loses the data source reference in the XDocument. The error occurs when trying to use GetDOM of thisXDocument which is a variable of XDocument set at _Startup.

    Any thoughts as to why I'm losing reference to the secondary data source on the second go around for the onafterchange event of the dropdown?
  • 08-03-2006 12:08 PM In reply to

    Re: GetListItemsConfig data source not accessible

    Well I managed to figure out a solution myself so I thought I'd share it. The problem with using a dropdown with the example had to do with what happened to the secondary datasources after the initial selection. Basically nodes were being moved and not replaced. So to fix the problem I modified the following:

    1.) Changed this line from:

    IXMLDOMNode fileQueryNode = thisXDocument.GetDOM("GetListItemsConfig").selectSingleNode("/GetListItemsConfig/QueryXmlString/Query ");

    to:

    IXMLDOMDocument document = thisXDocument.CreateDOM();
    document.preserveWhiteSpace = true;
    document.loadXML(thisXDocument.GetDOM("GetListItemsConfig").selectSingleNode("/GetListItemsConfig/QueryXmlString/Query ").xml);
    IXMLDOMNode fileQueryNode = document.documentElement;


    2.) Changed this line from:

    oQuery.appendChild(fileQueryNode);

    to:

    if( oQuery.firstChild != null )
    oQuery.replaceChild(fileQueryNode,oQuery.firstChild);
    else
    oQuery.appendChild(fileQueryNode);

    This first part created a new instance of the node so it was not removed on the second selection of the dropdown. The second part added a check to make sure you are not appending multiple query nodes when the second selection occurs.

    Thanks.
  • 08-03-2006 04:35 PM In reply to

    Re: GetListItemsConfig data source not accessible

    Glad you got your issue figured out.
    Great tip. Thanks for sharing this with us!
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.