Retrieve Values on the form - InfoPath Dev
in

InfoPath Dev

Retrieve Values on the form

Last post 02-21-2006 10:14 AM by ek38. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-16-2006 05:54 AM

    • ek38
    • Top 200 Contributor
    • Joined on 02-14-2006
    • Posts 54

    Retrieve Values on the form

    This sound simple, but I don't have a great familiarity with JS or XML.

    I have a field in my form tied to a data source. The path in the datasource looks like myFields>dataFields>d:NEWJOB>:comments

    I am using the command
    XDocument.UI.Alert(getNodeValue("/d:NewJob/d:comments", "Howdy"));

    I have tried several different combinations of the xpath unsuccessfully. I don't understand how the xpath works. Here is the line in the top of the scripting code.

    //<namespacesDefinition>
    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-03T21:59:21" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
    //</namespacesDefinition>

    The form template is stored in SharePoint. I don't know if that makes a difference.

    Am I making this too complicatied? I'm just trying to display a value of a field on my form to a dialog box.




  • 02-16-2006 09:39 AM In reply to

    Re: Retrieve Values on the form

    First, check out this awesome XPath tutorial:http://www.w3schools.com/xpath/default.asp

    To fix your XPath, try this statement instead:

    XDocument.UI.Alert(XDocument.DOM.selectSingleNode( "/dfs:myFields/dfs:dataFields/d:NEWJOB/comments").text);


    This will get the first comments node from the NEWJOB group. If you are trying to find a particular node in that group (say, if it's repeating) then you will need to use a node test, which you should learn about in the tutorial above.

    I hope this helps, good luck!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-16-2006 12:56 PM In reply to

    • ek38
    • Top 200 Contributor
    • Joined on 02-14-2006
    • Posts 54

    Re: Retrieve Values on the form

    Matt,

    Thanks for the response. I am in the process of going through the tutorial. Thanks for the tip.

    We put the code in and we get the following message:
    The following error occurred:
    Object required
    File:script.js
    Line:133

    I'm troubleshooting now any suggestions would be appreciated. Is there supporting code that is needed that perhaps creates the XDocument object?


    quote:
    Originally posted by MFaus

    First, check out this awesome XPath tutorial:http://www.w3schools.com/xpath/default.asp

    To fix your XPath, try this statement instead:

    XDocument.UI.Alert(XDocument.DOM.selectSingleNode( "/dfs:myFields/dfs:dataFields/d:NEWJOB/comments").text);


    This will get the first comments node from the NEWJOB group. If you are trying to find a particular node in that group (say, if it's repeating) then you will need to use a node test, which you should learn about in the tutorial above.

    I hope this helps, good luck!

    ---------------
    Matt Faus
    InfoPath Dev Texas


  • 02-21-2006 10:14 AM In reply to

    • ek38
    • Top 200 Contributor
    • Joined on 02-14-2006
    • Posts 54

    Re: Retrieve Values on the form

    Matt,

    After going through the tutorial, we figured out why we were getting the error on line you suggested. All that was missing to make your suggestoin work was an "@comments" instead of just "comments".

    When we click on properties of comments and go to the details tab, it stated comments was an attribute and did not give a namespace. This field is pulled from a database., i.e. we did not create the field.

    Are all fields that are linked to a database always attribute fields? In the tutorial, the suggestion was to stay away from attribute fields and create elements instead.

    Your thougths?

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