Reopen Closed Appointment Using JavaScript in D365 CRM
Introduction:
When an appointment is closed in D365 CRM, the appointment is not editable. There can be a requirment 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.
Conclusion: You can Activate and edit the appointment, once done user can click on Mark Complete, to close the appointment.
Related posts:

Resolving SSL/TLS Secure Channel Trust Errors in Dynamics 365 Finance and Operations

How to change a Bill of material (BOM) item on a production order
How to Set Up a Local Development Environment for D365 Finance and Operations Without Azure Costs
![Shopify Meets Dynamics 365 Finance and Operations: A Guide to Integration [Part 2]](https://www.cloudfronts.in/wp-content/uploads/2024/12/DALL·E-2024-12-14-12.29.44-A-professional-illustration-depicting-the-integration-between-Shopify-and-Dynamics-365-Finance-and-Operations.-The-image-shows-Shopify-on-one-side-wit-150x150.webp)
