RE: How to copy date and time field values from parent record to child record in cloning record
Hi Sandy,
Do you want to get year, month and date(even with hour and minute) from value in Crm date and time field value and then format them in format you want and set it to child record date and time field?
You could take below code as reference:
var crmDate = Xrm.Page.getAttribute("parent_date").getValue();
var convertDate = new Date(crmDate);
var year = convertDate.getFullYear();
var month = convertDate.getMonth() + 1;
var day = convertDate.getDate();
var hour = convertDate.getHours();
var minute = convertDate.getMinutes();
convertDate.setDate(day + 3);
var newDate1 = month+"/"+convertDate.getDate()+"/"+year;
var newDate2 = month+"/"+convertDate.getDate()+"/"+year+" "+hour+":"+minute;
var newCrmDate = new Date(newDate1);
Xrm.Page.getAttribute("child_date").setValue(newCrmDate);
Please point out if I have any misunderstanding.
Regards,
Leo