I am trying to auto-populate the date fields on page load event.
I have the following code:
var today = new Date();
today = dd+'/'+mm+'/'+yyyy; //today is in this format
var dateCreated = Xrm.Page.getAttribute("dateCreated").getValue(); //date only, read-only, business required
var dateTimeEntered = Xrm.Page.getAttribute("dateTimeEntered").getValue(); //datetime
if(dateCreated == null)
{
Xrm.Page.getAttribute("dateCreated").setValue(today);
}
Issue: The value (today) is not set.
I tried Business rules, but date can not be calculated when the record has not yet been created
The workflow does not have anything to populate fields, before the record is created (only after).
The system "createdon" and "createdby" fields, don't auto-populated on load either, only on save.
I was able to populate custom "newcreatedby" with the code above, but dates are not being populated.
Thanks,