The fact that you have a "function" indicates you are using JScript and not C#, but you implemented the C# code. Switch to using the JScript code.
--
Greg Collins [InfoPath MVP]
Please visit:
http://www.InfoPathDev.com
Here's what I put in the edit form code for the submit:
function CTRL186_7::OnClick(eventObj)
{
// submit code
if(Convert.ToInt32(thisXDocument.DOM.selectSingleNode("//my:WeekTotal").text) <= 35)
thisXDocument.PrintOut();
thisXDocument.Submit();
}
when i press submit it says there was an error in the code and doesn't tell
where.
any idea?
:
Do you want to print before submit?
--
Greg Collins [InfoPath MVP]
Please visit:
http://www.InfoPathDev.com
Also, do i need to have the print if statement before the submit in the code?
:
Is there more than one WeekTotal field? If so then the XPath should be more specific. You also might want to try a more definite conversion to an integer...
Also, are you using JScript or C#? The code you presented below assumed you were using C# for the conversion to "(int)" but then mixed in non-managed code by calling "XDocument" instead of "thisXDocument". Here's a fix for both C# and JScript just in case.
----------
C#:
----------
if(Convert.ToInt32(thisXDocument.DOM.selectSingleNode("/my:FullXPath/my:WeekTotal").text) <= 35)
thisXDocument.PrintOut();
----------
JScript:
----------
if(parseInt(XDocument.DOM.selectSingleNode("/my:FullXPath/my:WeekTotal").text) <= 35)
XDocument.PrintOut();
--
Greg Collins [InfoPath MVP]
Please visit:
http://www.InfoPathDev.com
I'm addressed this in a previous topic but still no avail.
On Submit On_Click I need to run a submit, then an If statement that says if
the node my:WeekTotal < 35 then print. If it's above 35 I don't need it to
do anything but close like normal. Here's what someone else recommeded to me
but it didn't work:
XDocument.Submit();
if((int)XDocument.DOM.selectSingleNode("//my:WeekTotal").text <= 35){
XDocument.PrintOut();
}
any help would be nice
PS:I'm still not 100% if this needs to be a Fully trusted form.