XPATH code help- Set default value of a field to be the content of 2 different data sources - InfoPath Dev
in

InfoPath Dev

XPATH code help- Set default value of a field to be the content of 2 different data sources

Last post 07-08-2015 11:26 AM by tbrereto. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-08-2015 11:26 AM

    XPATH code help- Set default value of a field to be the content of 2 different data sources

    I have a form which has2 dropdown Lists.  These lists are populated from different .xml files ie MinorDistributionList, MajorDistribuitonList, etc etc. The "Minor" list is populated using the values of "MinorDistributionList.xml" and the Major" list is populated from "MajorDistributionList.xml."

     I want to create one text field which will populate with the "name" value of the dropdown if either one is selected.  I have been able to make it work one field using the below XPath.

    xdXDocument:GetDOM("MinorDistributionList")/MinorDistribution/Minor/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MINORDISTLIST]

    However now I need to modify the code in a way which will allow the same field to pull from the other "major" Dropdown.  Both dropdown will not contain data at the same time, so there should not be any conflicts. The code which makes the field populate with the "Major" value only is

    xdXDocument:GetDOM("MajorDistributionList")/MajorDistribution/Major/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MAJORDISTLIST] 

    Looking at this post: http://www.infopathdev.com/forums/p/27532/95371.aspx I attempted to modify my xpath to allow this field to do as I want.  My modified xpath is below:

    xdMath:Eval(xdMath:Eval(xdXDocument:GetDOM("MinorDistributionList")/MinorDistribution/Minor/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MINORDISTLIST], 'concat(substring(xdXDocument:GetDOM("MinorDistributionList")/MinorDistribution/Minor/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MINORDISTLIST], 1, xdXDocument:GetDOM("MinorDistributionList")/MinorDistribution/Minor/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MINORDISTLIST] * string-length(xdXDocument:GetDOM("MinorDistributionList")/MinorDistribution/Minor/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MINORDISTLIST])), substring(xdXDocument:GetDOM("MajorDistributionList")/MajorDistribution/Major/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MAJORDISTLIST], 1, (string-length(xdXDocument:GetDOM("MajorDistributionList")/MajorDistribution/Major/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MAJORDISTLIST]) > 1) * string-length(xdXDocument:GetDOM("MajorDistributionList")/MajorDistribution/Major/Name[../ID = xdXDocument:get-DOM()/my:myFields/my:MAJORDISTLIST])))'), "..")

    However when I try to load the form I get the following error message in the details section:

    MSXML5.DLL
    Reference to undeclared namespace prefix: 'my'.


    Error occurred during a call to property or method 'Eval'.

    Any insight here as to how i can change my xpath to allow this to work?  Thanks so much in advance

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