running xpath query on secondary data source issue - InfoPath Dev
in

InfoPath Dev

running xpath query on secondary data source issue

Last post 12-18-2009 07:57 AM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-18-2009 03:52 AM

    • buzzby
    • Top 200 Contributor
    • Joined on 07-11-2005
    • United Kingdom
    • Posts 60

    running xpath query on secondary data source issue

    Here is what i am trying to do.

     

    I have a WSS list with 2 columns Year and ProjectNumber. This is being used to create an incrementale number with the addition that the numbers start from 1 again at the begining of a new year.

    I have created a data source that points to this WSS list. I have then created a field that looks at this list and selects the MAX project number for the current year. Here is the code in from infopath

     

    max(@ProjectNumber[@Year = substring(now(), 0, 5)])

     

    This works great.

     

    What i would like to do is execute this data connection in code (easy) and then select the max value so that i can use it to create by reference number.

     

    I have tried the following but am now completely stuck.

     

    XPathNavigator xpn = this.DataSources["MasterProjectNumbers"].CreateNavigator();

    string xpath = @"xdMath:Max(xdXDocument:GetDOM('MasterProjectNumbers')/dfs:myFields/dfs:dataFields/dfs:MasterProjectNumbers/@ProjectNumber[../@Year = substring(xdDate:Now(), 0, 5)])";

    XmlNamespaceManager nsmgr = new XmlNamespaceManager(this.CreateNavigator().NameTable);

    nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

    nsmgr.AddNamespace("dfs", "dfs.xsd");

    MasterProjectNumber = xpn.SelectSingleNode(xpath, nsmgr).Value;

     

    MasterProjectNumber is a property that relates to a field i have on my form.

     

    Does any one have an idea how i can execute this type of query in c#. At the moment i have a field on my form that i will hide to do the filtering but i would rather do all of it inthe background.

     

    Buzz

    Filed under: ,
  • 12-18-2009 07:57 AM In reply to

    Re: running xpath query on secondary data source issue

    I'm not quite sure I understand why you want to use code here.  If all you want to do is store a temporary value and not have it in the main data source, I'd suggest placing it in an XML secondary data source.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.