NewFromSolution problems - InfoPath Dev
in

InfoPath Dev

NewFromSolution problems

Last post 03-17-2006 01:28 AM by danallason. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-15-2006 04:49 AM

    NewFromSolution problems

    Hi All,

    I have created a timesheet form for our supervisors to complete for each of their subordinates on a weekly basis. The data is then submitted to a database. As an ease of use issue more than anything - I would like to have a button that says "Submit and Fill Out Another" which submits the current timesheet and opens a fresh one. This can be done with rules alone but the user is required to fill in the 'InputBy' and 'Passcode' fields each time the new form is opened.

    I have tried using code to open a new form and copy the above two fields into the same fields on the new form. Unfortunately, my jscript is not what one would call 'exemplary'! This means that I am at a dead end with the following code:

    function submitAndAddAnother::OnClick(eventObj)
    {
    //Create a new form
    XDocument newForm = Application.XDocuments.NewFromSolution("\\server\pathname\Timesheets.xsn");
    //Get the current InuptBy data
    IXMLDOMNode inputByOld = thisXDocument.DOM.selectSingleNode("/fieldPath@InputBy");
    //Get the new InputBy field
    IXMLDOMNode inputByNew = newForm.DOM.selectSingleNode("/fieldPath/@InputBy");
    //Set the new field to the value of the old field
    inputByNew.text = InputByOld.text;
    }

    My problem being that this doesn't work! The error I get is along the lines of:
    Expected ';'
    File:script.js
    Line:58
    Where line 58 corresponds to the line where newForm is initialised.

    Also - if I have rules as well as code - will they both be run at onClick? Because otherwise I will have to submit and close the old form with code too...

    Thanks in advance of any help offered,
    Dan Allason
  • 03-16-2006 09:02 AM In reply to

    Re: NewFromSolution problems

    Hi Dan Allason,
    You should not give "XDocument" or "IXMLDOMNode" in script code, you should give "var" instead. That is the reason for the error message.
    One more thing in the path specified, every "\" should be escaped with another one.
    for ex: Your path should be "\\\\server\\pathname\\Timesheets.xsn"

    Regarding Rules and code getting called onclick, Yes they both will be called(Executed).
  • 03-17-2006 01:28 AM In reply to

    Re: NewFromSolution problems

    Thanks Agni! That now has the code compiling properly and I no longer get the error message. The problem now being that NewFromSolution doesn't open newForm (I am sure I have the filepath in the correct format). Should I be using different syntax? Any help would be great, Cheers!
    Dan
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.