Tech Support > Microsoft Windows > Windows CRM > OnChange-event for date inside a case not working correctly
OnChange-event for date inside a case not working correctly
Posted by michael on October 6th, 2004


For service --> cases I have added the picklist-field incidentstagecode and
created a new one called closed_date (as date).

Incidentstagecode has now two fields (open = 1, closed = 2).

For incidentstagecode I have added the following onChange-event:

var cd, s, dp;
if (crmForm.incidentstagecode.returnValue=2)
{
cd = new Date();
dp = "00" + (cd.getMonth() + 1);
s = dp.substr(dp.length-2,2) + "/";
dp = "00" + (cd.getDate());s += dp.substr(dp.length-2,2) + "/" +
cd.getYear();
crmForm.CFDclosed_date.value = FormatDate(ParseDate(s));
crmForm.CFDclosed_date.click();
}

As soon as I click in incidentstagecode on closed, I see the actual date,
which is as expected.

But as soon as I save and close, the today-date is gone.

What was my mistake?
--
Thanks,
Michael Theiss

Posted by Martin Flaherty on October 29th, 2004


Michael,

I think you may have to set the .returnValue date as well. I was just
working with an OnChange event for the prioritycode field to set a due date
(followupby). I found that the .value was what was displayed, but the
..returnValue was a different format.

Here is what we ended up with for a working OnChange code:

var now = new Date();
switch (document.crmForm.prioritycode.returnValue)
{
case '1':
now.setDate(now.getDate()+2);
document.crmForm.followupby.value = (now.getMonth() + 1) + '/' +
now.getDate() + '/' + now.getFullYear();
document.crmForm.followupby.returnValue = now.getFullYear() + '-' +
(now.getMonth() + 1) + '-' + now.getDate();
break;
case '2':
now.setDate(now.getDate()+3);
document.crmForm.followupby.value = (now.getMonth() + 1) + '/' +
now.getDate() + '/' + now.getFullYear();
document.crmForm.followupby.returnValue = now.getFullYear() + '-' +
(now.getMonth() + 1) + '-' + now.getDate(); break;
case '3':
now.setDate(now.getDate()+10);
document.crmForm.followupby.value = (now.getMonth() + 1) + '/' +
now.getDate() + '/' + now.getFullYear();
document.crmForm.followupby.returnValue = now.getFullYear() + '-' +
(now.getMonth() + 1) + '-' + now.getDate(); break;
}

Hope this helps. Let me know.

Thanx,
Marty Flaherty
mflaherty_at_techpg_dot_com

"michael" <michael@discussions.microsoft.com> wrote in message
news:4BDDCCF5-0D5C-4447-A9E6-743B26848C8A@microsoft.com...



Similar Posts