Expected ';' File:script.js - when opening form - InfoPath Dev
in

InfoPath Dev

Expected ';' File:script.js - when opening form

Last post 03-31-2006 04:39 AM by spudy. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 03-23-2006 08:23 AM

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Expected ';' File:script.js - when opening form

    I have a form with a button which is creating a new row in a repeating table. Except whenever I attempt to open the form I recieve the error:

    Expected ' ; '
    File:script.js
    Line:x
    IXMLDOMNode row = thisXDocument.DOM.selectSingleNode("//my:SORItemData");

    Tried everything I can think of but the error is always there. Any advice (other than give it up!)

    Many thanks.

    Spuddy
  • 03-23-2006 08:54 AM In reply to

    Re: Expected ';' File:script.js - when opening form

    Hi Spuddy, Welcome to the forum,

    You have to do like this,

    var row = XDocument.DOM.selectSingleNode("//my:SORItemData");

    This will work for you,

    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 03-23-2006 02:02 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Expected ';' File:script.js - when opening form

    Thanks for that. I am not familiar with .js - but now that I have made the changes the form loads but on clicking the button the following message occurs:

    Reference to undeclared namespace prefix: 'my'

    Thankyou for your help I realise that I now need to look at the XMLSchema and figure out the namespace. I thought this was the default as created by Infopath.

    Thankyou for you prompt reply...
  • 03-23-2006 02:15 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Expected ';' File:script.js - when opening form

    Changed the namespace prefix to //SORItemData but now fails on the clone line. Trial and error got me to that point - I am still trying to get my head round how to reference namespaces and elements correctly in script.

    Line it fails on: row = row.cloneNode(true);

    'null' is null or not an object - is this because the first row of the repeating table is empty?

    Many thanks

    Spudy
  • 03-23-2006 03:36 PM In reply to

    Re: Expected ';' File:script.js - when opening form

    Hi Paul,

    This sounds like a namespace issue. Removing the namespace from the select function call may have stopped the error on that line, but it does not mean that the XPath works! You will almost certainly need to add a reference to the namespace in order to get at this node.

    I think the information foudn in this HowTo should help:http://www.infopathdev.com/howto/tutorials/default.aspx?i=ed2cf0c5895f468995cdd081cf17fead
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-28-2006 12:42 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Expected ';' File:script.js - when opening form

    Thankyou Matt, but I am still lost.

    I have created a few textboxes, a dropdownlist, a button and a repeating table. My intention is to add a new row to the repeating table extracting information from the dropdown and textboxes when the button is clicked.

    I have previously extracted information from specific nodes without much difficulty. It is just this process of creating a new row in the table that I am stuck with.

    You refered to a link which talks about referencing namespaces of a secondary datasource. But I am looking to move data from one node to another in the same xml without looking at another datasource. I do not understand why I cannot do this.

    My book on all things Infopath is taking it's time to get here and I think this boils down to my fundamental lack of understanding on how Infopath hangs together.

    Here is my code behind:

    {
    var row = XDocument.DOM.selectSingleNode("/my:myFields/my:SORDetails/my:RepeatingData") ;
    row = row.cloneNode(true) ;
    row.selectSingleNode("my:SORQTY").text = "QTY" ;
    var parent = thisXDocument.DOM.selectSingleNode("/my:myFields") ;
    parent.appendChild(row) ;

    And from the extracted Template.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:new-design-1:-myXSD-2006-03-03T16-21-10" href="manifest.xsf" solutionVersion="1.0.0.9" productVersion="11.0.6565" PIVersion="1.0.0.0" ?>
    <?mso-application progid="InfoPath.Document"?>
    <my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-03-03T16:21:10" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
    <my:SORDetails>
    <my:RepeatingData>
    <my:SORQTY></my:SORQTY>
    </my:RepeatingData>
    </my:SORDetails>
    </my:myFields>

    Any further help would be great!

    Thanks
  • 03-28-2006 04:16 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Expected ';' File:script.js - when opening form

    It has taken me a while. Part of my confusion is that I thought the namespace had been declared and that on viewing the code from button properties it simply hid this detail. I have since realised that the namespace was not declared. So Matt, thankyou for your advice. It looks like I am on the right path now, and it seems to have the x factor required.

    Once again thankyou very much for the guidance.
  • 03-28-2006 09:20 AM In reply to

    Re: Expected ';' File:script.js - when opening form

    Cool, I'm glad you're starting to get the hang of it! I noticed a few bugs in your code and I have made some revisions:

    var row = XDocument.DOM.selectSingleNode("/my:myFields/my:SORDetails/my:RepeatingData") ;
    row = row.cloneNode(true) ;
    row.selectSingleNode("my:SORQTY").text = "QTY" ;
    row.parentNode.appendChild(row) ;

    Hope this helps!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-31-2006 04:39 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Expected ';' File:script.js - when opening form

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