When I am trying to modify the appointment all day start and end times (from 12 - 12 to 9 -5) and I have the below function which used to do just that on the legacy form, it does all sorts of strange things.
First some background, the function is registered on onChange of the alldayevent checkbox and checks for whether said checkbox returns true. Anyway, when trying to set recurrence this does not work. It is something to do with the way that datetimes now work, I think. I could use any sort of guidance with this as I have nearly had it with this. The client requirement is the reason for the modification of start and end times to 9 - 5.
The expected behavior is that when the alldayevent checkbox is selected, even though default mscrm behavior is to hide the start and end time fields on the form, it still ought to change the values themselves. However, when selecting the recurrence option from the ribbon, the start and end times are the first two fields on the popup form. They should, given that the below code runs onChange of the checkbox, show 9:00 am to 5:00pm.
Important clue/quirk. If you deselect the alldayevent checkbox, while still on the main form, the start and end times DO show 9 -5. But, even so, the recurrence form does not. *shrugs*
The below script was borrowed and copypasta style (likely from this forum), and I don't entirely follow how it is doing. But, given that it did work in the legacy client, it does suggest that this is due to something specific to the new interface.
function SetAllDayEventTimes() {
//if (xrmPage.ui.getFormType() == 1 && Xrm.Page.getAttribute("isalldayevent").getValue() == true )
if (xrmPage.getAttribute("isalldayevent").getValue() == true) {
var duration = xrmPage.getAttribute('scheduleddurationminutes');
duration.setValue(0);
duration.setValue(60 * 8);
var start = xrmPage.getAttribute('scheduledstart');
var end = xrmPage.getAttribute('scheduledend');
var newStart = new Date(start.getValue());
var startHour = newStart.getHours();
newStart.setHours(9, 0, 0);
start.setValue(newStart);
var newEnd = new Date(start.getValue());
var endHour = newEnd.getHours();
newEnd.setHours(endHour 8);
end.setValue(newEnd);
xrmPage.getAttribute("scheduledstart").setValue(newStart);
xrmPage.getAttribute("scheduledend").setValue(newEnd);
}
}
Thanks in advance for any suggestions