Hi everyone,
we are facing a really strange issue came up suddenly yesterday morning without any apparent reasons (no new customizations installed or solutions updated in Solution History): our customer is completely prevented from creating appointments through the classic main form (which we have customized a bit in the past, but not touched in the last couple of months) getting the classic error "The requested record was not found or you do not have sufficient permissions to view it".
Before you asks, there are not workflows or plugins that change the records' ownership on creation.
After some research, i found out that everything is caused because an inexplicable CRM behaviour on first appointment onSave form event; here's the result of my attempts:
- i wrote a little piece of code for the OnSave form event that is alerting the record Id through
formContext.data.entity.getId()
function;
- if i create an appointment inside Sales Hub app, everything runs fine, but we have also a main difference here because since Wave 2 release Sales Hub opens activities forms as modals on top of the page

As you can see the code alerts nothing, as we're normally expecting from the onSave event that is triggered immediately before the record save finalization.
- Now if we try this in other apps, such as our custom app called "Visite" or the legacy "Dynamics 365 - custom" app, the creation form for activities is opened as usual as a page

As you can see, with the very same form (just opened differently) and the very same piece of code now we managed to alert the record id during the onSave event, so before the record was committed to the CRM DB.
This anomaly leads to an error in OOB library “Appointment_main_system_library.js”, in function “Activities.SchedulingEngine.BookOrReScheduleAppointment” which is also triggered during onSave event form

As you can see, the "IF" condition checks for the presence of the record Id during save, assuming to not to have a record id yet on create in order to launch the “Create Flow” which triggers the BookRequest.
Due to our anomaly we have a record id already during creation before the save finalization; this bring us in the other branch of the condition (the one meant for the update) which triggers RescheduleRequest, the source of our error:

Does anyone has an explanation for this strange and sudden behaviour? As i said we haven't touched the system in a couple of months and users were able to create records without errors since 48h ago.
Thanks in advance.