Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Problem Updating a Field With Current Date

$
0
0

Hi'

On my Case form I have a locked field called "Date Logged". If this field is empty, I want to fill it with the current date.
The name of the field is "new_datelogged".

On the Case form properties, I added in a javascript function (below) and on the Form event handler, I added in the function setToday
and set the parameter to "new_datelogged".

The alert boxes give me the correct information, however the "new_datelogged" is not updated.

I can't figure out what I've done wrong.

function setToday(sOldDate)
{
	var sTemp = Xrm.Page.getAttribute(sOldDate).getValue();

	if (sTemp == null)
	{

alert ("In here");
		var currentTime = new Date();
		var month 	= currentTime.getMonth() + 1;
		var day 	= currentTime.getDate();
		var year 	= currentTime.getFullYear();
		var sToday    = month + "/" + day + "/" + year;

alert (sToday);

	   	Xrm.Page.data.entity.attributes.get(sOldDate).setValue(sToday);
	}

}


Viewing all articles
Browse latest Browse all 8223

Trending Articles