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