When an appointment is closed in D365 CRM, the appointment is not editable. There can be a requirement when Users wish to edit the closed appointment and add some missing data. This can be achieved by adding a new button on the Appointment form.
Solution:
Add a new button and use below JavaScript.
var AppointmentForm =
{
setActive:function(primaryControl)
{
var formContext= primaryControl;
var status= formContext.getAttribute("statecode").getValue();
if (status==1)
{
formContext.getAttribute("statecode").setValue(0);
formContext.getAttribute("statuscode").setValue(1);
formContext.data.save();
}
}
}
To understand the status and status reason details, you can refer the Microsoft document- https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/appointment?view=dynamics-ce-odata-9
Note that, you need to update both statecode and statuscode, trying to update only one will give a system error.
You can Activate and edit the appointment, once done user can click on Mark Complete, to close the appointment.
Comments
Post a Comment