I have two date time fields. In the first field, if the date is set, then in the second date time field, the date should be automatically populated with this format.
For example:
Start date: 1: 09/30/2016
Then result should be as following:
End date : 09/29/2017.
Following is my code:
function SetOneplusyearminus1date() { debugger; var start = Xrm.Page.getAttribute("msdyn_startdate").getValue(); if (start != null) { var endDate = start.setDate(start.getDate() - 1); //To get the result date as -1 of original date var endYear = start.setYear(start.getFullYear() + 1); var ending = endYear + endDate; Xrm.Page.getAttribute("msdyn_enddate").setValue(ending); } }
I am getting a different result.
So please help me with your suggestions.