Referencing Node in eventObj.Site - InfoPath Dev
in

InfoPath Dev

Referencing Node in eventObj.Site

Last post 11-29-2012 08:16 AM by cmschofield. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 11-28-2012 11:18 AM

    Referencing Node in eventObj.Site

    I'm completely new to InfoPath (since yesterday) and am attempting to retrieve a value from a node. I'm working inside an OnAfterChange event method and working with the eventObj argument. When I output the eventObj.Site.xml to an alert, this is what's shown:

    <listdata class="entity">
        <_DocumentHash>1d134344a6c52b432b8eb6a5e67cfee4</_DocumentHash>
        <Item_no>5860</Item_no>
        <Trailer_no>5881</Trailer_no>
        <Bol_no>PR-000781</Bol_no>
        <Unit_cnt>4.00</Unit_cnt>
        <Seal_no>12345</Seal_no>
        <LooseCartons>5</LooseCartons>
    </listdata>

    I need to get the value of the Bol_no and LooseCartons nodes. However the following code returns a JScript error:

    var looseCartons = eventObj.Site.getSingleNode("LooseCartons").text;

    Error: object doesn't support this property or method.

    Am I referencing them correctly? Any help would be much appreciated.
    Thank you in advance!
  • 11-28-2012 11:21 AM In reply to

    Re: Referencing Node in eventObj.Site

    selectSingleNode, I believe, not getSingleNode....
    Hilary Stoupa

  • 11-28-2012 11:58 AM In reply to

    Re: Referencing Node in eventObj.Site

    Yeah, that's embarrassing. Thanks.

    I've fixed that but now I'm getting another error "Object required" on Alert line below:

    var t = eventObj.Site.selectSingleNode("/listdata/LooseCartons");
    XDocument.UI.Alert("TEXT: " + t.text); // Error happens here.
  • 11-28-2012 12:21 PM In reply to

    Re: Referencing Node in eventObj.Site

    My guess would be that t is null because your XPath is incorrect. I'd try just "LooseCartons" like in your original post - but is there a namespace prefix on that XML? You may be missing that....

    Hilary Stoupa

  • 11-28-2012 01:52 PM In reply to

    Re: Referencing Node in eventObj.Site

    I was wondering the same thing about the prefix so I tried using some that match those on the data source to no avail and I've also tried it with only "LooseCartons". Also, the eventObj.Site.xml did now show a prefix in any of the xml nodes. I'm not sure if that matters, though. Aside from the data sources in the InfoPath Design, is there somewhere else I should be looking to determine the prefixes?

    Is there an online documentation reference I can look at besides the Office Dev Center website?

    Thank you very much for taking the time to respond.
  • 11-28-2012 02:47 PM In reply to

    Re: Referencing Node in eventObj.Site

    Is this in your main data source? Or a 2DS? I'm guessing you are using InfoPath 2003 - is that correct?
    Hilary Stoupa

  • 11-28-2012 03:09 PM In reply to

    Re: Referencing Node in eventObj.Site

    It's a secondary data source and it's InfoPath 2007.
  • 11-28-2012 03:15 PM In reply to

    Re: Referencing Node in eventObj.Site

    If you are in IP 2007, getting the XPath is easy - right click the node in the task pane and select Copy XPath.

    Now, you will only need the XPath from listData to LooseCartons, based on your original post, but copying the XPath and pasting into a text editor will at least show you the correct namespace for your node.

    Hilary Stoupa

  • 11-29-2012 08:16 AM In reply to

    Re: Referencing Node in eventObj.Site

    Hilary,

    Thank you very much taking the time to troubleshoot this with me. My co-worker recommended another solution through the IP Design mode that works perfectly. Due to our deadline I'll have to try and figure this out later.

    Thank you again.

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