With the following code, I try to set 2 field values (LastUpdated_by and LastUpdated_time) at the moment a custom submit button is pressed.
function CmdSave::OnClick(eventObj)
{
var curDate = new Date()
var sLastUpdated_by = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:EMPLOYEE_NOT_ON_SITE/@LastUpdated_by");
var sLastUpdated_time = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:EMPLOYEE_NOT_ON_SITE/@LastUpdated_time");
sLastUpdated_by.text = GetLogin();
sLastUpdated_time.text = curDate
try
{
// save all changes made.
XDocument.Submit();
}catch(Oeps)
{
XDocument.UI.Alert("Er is een fout opgetreden: \n\n\tOfwel is er een verplicht veld niet ingevuld (rood *),\n\tOfwel is er een ongeldige waarde ingevuld (rode stippellijn)");
return;
}
var objEmail = XDocument.DataAdapters("Sendto2Approver")
objEmail.Submit()
}
But it doesn't work. The variables sLastUpdated_by and sLastUpdated_time point to null. I'm sure one of you knows what I am doing wrong this time.
Thanks in advance for your help.
Hans.
Infopath 2003 / Jscript