Can't write value to XML node

B

boreal

What am I missing here? I'm sure it's something trivial...

The date is not being written to the DateMonday field. Why?

I'm using InfoPath sp1 & yes I know about the current() function in
InfoPath...

function XDocument::OnLoad(eventObj)
{
var FormDate = new String();
var CurrentDate = new Date();
var m = CurrentDate.getMonth() + 1;
var d = CurrentDate.getDate();
var y = CurrentDate.getFullYear();
var day = CurrentDate.getDay();
if (m < 10)
m = "0" + m;
if (d < 10)
d = "0" + d;

if (day = 1)
{
FormDate = (d + "/" + m + "/" + y);
var objXMLNode =
XDocument.DOM.selectSingleNode("/my:myFields/my:DateMonday");
if (objXMLNode.getAttribute("xsi:nil"))
{
xmlNode.removeAttribute("xsi:nil");
objXMLNode.text = FormDate;
}
}
}
 
B

boreal

Patrick

Thanks for the quick response!

I changed xmlNode to objXMLNode and I commented out the "if (day = 1)" to
force the value to be written into the DateMonday field, but still no go.

I'm not getting an error message and the xsi:nil is getting removed
properly. When I look at the infopath form's XML, there is nothing
attributed to the DateMonday node.

Is my assignment (objXMLNode.text = FormDate) incorrect?
 
B

boreal

Nevermind - I've got it working.

I removed the getAttribute and removeAttribute lines regarding xsi:nil and
the code works.
 
P

Patrick Halstead [InfoPath MVP]

worked for me fine.

boreal said:
Patrick

Thanks for the quick response!

I changed xmlNode to objXMLNode and I commented out the "if (day = 1)" to
force the value to be written into the DateMonday field, but still no go.

I'm not getting an error message and the xsi:nil is getting removed
properly. When I look at the infopath form's XML, there is nothing
attributed to the DateMonday node.

Is my assignment (objXMLNode.text = FormDate) incorrect?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top