Unable to write data to text control using vbscript - InfoPath Dev
in

InfoPath Dev

Unable to write data to text control using vbscript

Last post 06-07-2007 02:04 PM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-06-2007 10:57 AM

    • haket
    • Not Ranked
    • Joined on 05-24-2007
    • Posts 6

    Unable to write data to text control using vbscript

    To update a control field one of the articels uses the following code:

    strStartDate = XDocument.DOM.selectSingleNode _

    ("/my:myFields/my:startDate").text

    I am trying to use the same syntax to populate a text field in my form:

    XDocument.DOM.selectSingleNode("/my:myFields/my:dataFields/d:Table1/d:Table1Item3").text = "abc"

    However, The following error occurred:

    Object required: 'XDocument.DOM.selectSingleNode(...)'
    File:script.vbs
    Line:23

    My form is connected to database with two tables - namely "Table1" as the Primary and the other one "Table2".

    any help please.

     

  • 06-06-2007 03:19 PM In reply to

    Re: Unable to write data to text control using vbscript

    The select is failing, thus the .text property not valid.

    Sounds like the issue is likely with the namespaces. Assuming the node names are all accurate, check to make sure each node has the appropraite namespace. For example, "my:" on dataFields looks suspicious to me.

  • 06-07-2007 01:22 AM In reply to

    • haket
    • Not Ranked
    • Joined on 05-24-2007
    • Posts 6

    Re: Unable to write data to text control using vbscript

    The node names are as in the Data source. I think you are right the issue may be with the namespaces because i have no clue how they work. is there a quick tutorial i can get my hands on.

    This is what my Data source looks like if that is of any help. (For some reaon i am unable to upload its image file hence this representattion below).

    Table1 is the primary table with three elemenst namely Table1Item1, Table1Item2 and Table1Item3. Table2 is another table with 3 elements too.

    -----------------------------------------------------------

    - myFields

      + queryFields

      - datFields

        - d:Table1

            Table1Item1

            Table1Item2

            Table1Item3

        - Table2

             Table2Item1

             Table2Item2

  • 06-07-2007 08:34 AM In reply to

    • haket
    • Not Ranked
    • Joined on 05-24-2007
    • Posts 6

    Re: Unable to write data to text control using vbscript

    i have my answer:

    XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:Table1/@Table1Item3").text = "abc"

    though dont ahve a clue why "dfs" and not "my" and "@". Any tutorial i can read to understand these?

     

  • 06-07-2007 02:04 PM In reply to

    Re: Unable to write data to text control using vbscript

    The '@' (typically pronounced 'at') symbol is used to differentiate an 'at'tribute from an element. So 'Item' is an element, while '@item' is an attribute.

    Namespaces help keep names distinct and different. For example, there are lots of people in the world named Greg, but there are not as many named Greg Collins... so in this human name example, my personal namespace could be my surname and I could be represented as collins:greg to differentiate me from jones:greg or smith:greg. If someone called out for smith:greg, I would have no reason to answer. Make sense?

    InfoPath uses the 'my' namespace for everything, but a data source has a few different namespaces they use, as you see in your example 'dfs', 'd' and no namespace at all in the case of the attribute.

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