Hi all,
I have a requirement to validate if some of the custom fields on the Appointment form have been filled in when Appointment is being marked Complete using out-of-the-box Mark Complete ribbon button. I cannot seem to intercept this event though. I created a js function that fires when the form is being saved and it does fire, but the statecode value is 0 (open) when it fires when I'm expecting 1 (complete). I even created an event on value change of the statecode field and it doesn't fire at all. It feels like CRM changes the record status in a way that browser isn't made aware of this change. Anyone knows how I can achieve this?
Thanks,
-TS.
Hi Ravi, yes I think you're spot on. I couldn't find any way to intercept that event, so I ended up hiding the buttons (there's also Close Activity button that lets your either Cancel or Mark Complete) and adding custom buttons with proper enable rules to replace them. Luckily, just setting the statecode and statuscode in javascript did the job so no need to call WEB API. I appreciate your help!
Hi,
The only form events you can intercept in javascript are onload, onsave, field on change (others are related to tabs etc). Mark Complete is not an event but a functionality on activities which does certain things and then changes the status. This functionality calls some internal JavaScript method.
With that said, the possible solution would be to use ribbon workbench, find the system method being called on Mark Complate. Replace that with you custom JavaScript method, in your custom javascript method, do you custom validation and then call the system method.
Alternatively you can hide the system Mark Complete button and create your custom Mark Complete button, within this call you javascript validation and once everything is fine, you can either use web api to marke the appoint as complete or set some field which trigger oob workflow to mark the appointment as complete.
Hope this helps.