Need help setting Current Row field on repeating table from another view - InfoPath Dev
in

InfoPath Dev

Need help setting Current Row field on repeating table from another view

Last post 01-13-2010 03:15 PM by vinnyng. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-13-2010 12:12 PM

    Need help setting Current Row field on repeating table from another view

    Hello,

    I have a repeating table that has a button to go get the "ExtPartNum" from another view called "Get Part" and also set the CurrentRow field from my Line field. The "Get Part" view is a search with a text box and button to retrieve a web service and fill out the repeating table with a matching Part Number pattern. So I created a rule to set a field value for the main view's ExtPartNum to equal to the selected PartNum. Here is my Source code below for those 2 button rules for InfoPath. I get this error when clicking on the button on the Get Part view.

    Error :

    System.Xml.XPath.XPathException
    Expression must evaluate to a node-set.

    Rule on Main View: 

       <xsf:ruleSet name="ruleSet_13">
       <xsf:rule caption="Rule 1" isEnabled="yes">
        <xsf:assignmentAction targetField="../../my:CurrentRow" expression="my:line"></xsf:assignmentAction>
        <xsf:switchViewAction view="Get Part"></xsf:switchViewAction>
       </xsf:rule>
      </xsf:ruleSet>

     

     Rule on Get Part View:


      <xsf:ruleSet name="ruleSet_14">
       <xsf:rule caption="SetExtPartNum" isEnabled="yes">
        <xsf:assignmentAction targetField="xdXDocument:get-DOM()/my:travelRequest/my:group1/my:Row[position() = /my:travelRequest/my:CurrentView]/my:ExtPartNum" expression="ns4:PartNumber"></xsf:assignmentAction>
        <xsf:switchViewAction view="Create New Request"></xsf:switchViewAction>
       </xsf:rule>
      </xsf:ruleSet>

  • 01-13-2010 12:23 PM In reply to

    Re: Need help setting Current Row field on repeating table from another view

    The weird thing is that it correctly sets the value to the correct row but throws the error "Expression must evaluate to a node-set." for some odd reason.

  • 01-13-2010 02:24 PM In reply to

    Re: Need help setting Current Row field on repeating table from another view

    Ok, it looks like I might of caused my own error. I also had old code from the button event that produced that error and after commenting it out it stopped producing it. So the problem I have now is that Web based Infopath Forms do not support the XPath function position(). So it looks like I might have to write c# managed code to replicated the same thing unless anybody knows another way through Rule based. If not, a sample c# code would be great.

     Thanks,

    Vinny

  • 01-13-2010 03:15 PM In reply to

    Re: Need help setting Current Row field on repeating table from another view

    Ok, here is the c# managed code equivalent.

     

    public void btnSelPartNum_Clicked(object sender, ClickedEventArgs e)

    {

    XPathNavigator root = MainDataSource.CreateNavigator();

    XPathNavigator container = root.SelectSingleNode("/my:travelRequest/my:group1/my:Row[position() = /my:travelRequest/my:CurrentRow]/my:ExtPartNum", NamespaceManager);

    if (container != null)

    {

    container.SetValue(e.Source.SelectSingleNode(
    "ns4:PartNumber", NamespaceManager).Value);

    XPathNavigator container2 = root.SelectSingleNode("/my:travelRequest/my:group1/my:Row[position() = /my:travelRequest/my:CurrentRow]/my:Description", NamespaceManager);

    if (container2 != null)container2.SetValue(e.Source.SelectSingleNode("ns4:MarketingDescription", NamespaceManager).Value);

     

    }

    }

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