Filtering and retrieving sharepoint list data - InfoPath Dev
in

InfoPath Dev

Filtering and retrieving sharepoint list data

Last post 05-31-2010 06:55 AM by arcad. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-27-2010 08:32 AM

    • arcad
    • Not Ranked
    • Joined on 05-10-2010
    • Posts 15

    Filtering and retrieving sharepoint list data

    Hello all,

    I am trying to retrieve specific rows from sharepoint only when a specific value in infopath equals a specific value in SharePoint.

    Here is a piece of code

    XPathNavigator secDSNav = DataSources["SharePoint Data"].CreateNavigator();

    string test = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Car/my:Car_Model"_IP", NamespaceManager).Value;

    // Retrieve the rows of the secondary data source

    XPathNodeIterator rows = secDSNav.Select("/dfs:myFields/dfs:dataFields/dfs:SPData[@Car_Model_SP = 'test']", NamespaceManager);

     

    It works fine if i change the[@Car_Model = 'test']",  by a real value that exists in the list, e.g [@Car_Model = 'bmw']",   but I cant filter using the variable test.

    Do you have any ideas?

    Thanks

  • 05-27-2010 09:39 AM In reply to

    Re: Filtering and retrieving sharepoint list data

    When you use the variable test, your XPath looks like this, right?

    "/dfs:myFields/dfs:dataFields/dfs:SPData[@Car_Model_SP = '" + test + "']"

    Hilary Stoupa

  • 05-27-2010 10:23 AM In reply to

    • arcad
    • Not Ranked
    • Joined on 05-10-2010
    • Posts 15

    Re: Filtering and retrieving sharepoint list data

    Thanks a lot! My syntax was wrong.

  • 05-31-2010 06:55 AM In reply to

    • arcad
    • Not Ranked
    • Joined on 05-10-2010
    • Posts 15

    Re: Filtering and retrieving sharepoint list data

    I am trying to set conditions when filtering. I am using the string-length function to determine if strings exist or not (FilterModel and FilterManufacturer are 2 drop downs). However, i am getting an "expression must evaluate to a node-set" error. Is there another way to determine the existence of a string when filtering? Thanks in advance!

     

    XPathNavigator secDSNav = DataSources["SP_Data"].CreateNavigator();

    string FilterModel = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Car/my:Car_Model", NamespaceManager).Value;

    string FilterManufacturer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Car/my:Car_Manufacturer", NamespaceManager).Value;

    XPathNodeIterator rows = secDSNav.Select("/dfs:myFields/dfs:dataFields/dfs:group[(@Cat = 'Car' and @Car_Model = '" + FilterModel + "' and @Car_Manufacturer = '" + FilterManufacturer + "') or (@Cat = 'Car' and @Car_Manufacturer = '" + FilterManufacturer + "' and string-length('" + FilterModel + "') = 0) or (@Cat = 'Car' and string-length('" + FilterManufacturer + "') = 0 and string-length('" + FilterModel + "') = 0 )]", NamespaceManager);

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.