Help me SORT this out....please!!! - InfoPath Dev
in

InfoPath Dev

Help me SORT this out....please!!!

Last post 05-02-2006 08:31 AM by bad_andy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-01-2006 02:19 PM

    Help me SORT this out....please!!!

    I'm clueless when it comes to jscript. That's why I chose a sample form as a basis for mine. Here's the deal...I've created a form with a repeating table so that the user can input as many lines as necessary. Now I want to give other users the ability to sort the form data as they see fit. Since the Asset Tracking sample form is conceptually very similar, I copied the entire code over to my form and named my fields accordingly. Of course, now I have a lot more code than I need, but that's a good problem to have, as long as the code works. Problem is, it doesn't work. When I click the Sort button, which corresponds to the reSort function in Asset Tracking, I get an error in the getNode function. The error points to the "return XDocument" line below.

    Since I'm clueless at this stuff, can someone explain why this would be giving me an error? What sort of things should I be looking for to correct this problem?


    /*------------------------------------------------------------------------------
    getNode()
    ------------------------------------------------------------------------------*/
    function getNode(xpath)
    {
    // Both XML node and absolute XPath are allowed.
    if (typeof(xpath) == "string")
    return XDocument.DOM.selectSingleNode(xpath);
    else
    return xpath;
    }
  • 05-01-2006 06:40 PM In reply to

    Re: Help me SORT this out....please!!!

    This seems like your XPath is wrong. Can you paste the string that you pass to the getNode() function?

    If this string is automatically generated you can add a QuickWatch in the Microsoft Script Editor that will tell you what the value of this variable is.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-02-2006 08:31 AM In reply to

    Re: Help me SORT this out....please!!!

    Thanks for the reply, and sorry for not getting back sooner. I haven't been able to get very far with QuickWatch, so this is all I can give you for now:

    The function that calls the getNode() functions seems to be getNodeValue:

    /*------------------------------------------------------------------------------
    getNodeValue()
    ------------------------------------------------------------------------------*/
    function getNodeValue(xpath, defaultValue)
    {
    var xmlNode = getNode(xpath);

    if (isInvalidOrEmpty(xmlNode))
    return (arguments.length > 1) ? defaultValue : "";
    else
    return xmlNode.text;
    }

    and the function that calls getNodeValue is the one that handles the button:

    function btnReSort::OnClick(oEvent)
    {
    // Avoid side effects when DOM is read only.
    if (XDocument.IsDOMReadOnly)
    return;

    // It is used by comparison function, and to flag sort in progress.
    // The generation of unique keys is suppressed while sort is in progress.
    g_xpathSortBy = getNodeValue("/at:assetTracking/at:tempSortBy");

    if (!g_xpathSortBy)
    return;

    sort("/at:assetTracking/at:assets", "at:asset", compareAssets);

    // Unblock generation of unique keys.
    g_xpathSortBy = "";
    }
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.