Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

How to intercept 'Mark Complete' button click on Appointment form with javascript?

Posted on by 105

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.

  • Tony Suslovich Profile Picture
    Tony Suslovich 105 on at
    RE: How to intercept 'Mark Complete' button click on Appointment form with javascript?

    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!

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: How to intercept 'Mark Complete' button click on Appointment form with javascript?

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans