Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Fixing appointment time be default to 1hr from 30 min

Posted on by Microsoft Employee

I want to change the appointment timing which is by default as 30 minutes to 1 hr. I can understand that I have to write a JavaScript. But I am unable to write the same. Can anyone please help me. Thanks in advance

Categories:
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fixing appointment time be default to 1hr from 30 min

    This code works. Thanks Alex.. :-)

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Fixing appointment time be default to 1hr from 30 min

    Hi,

    simple set the End time with Start Time +30 minutes  and update the duration with 60 minutesvia JS  onload event

    function set()

    {

    if(Xrm.Page.ui.getFormType() == 1)

    {

    var start =Xrm.Page.getAttribute("scheduledstart").getValue(); // get start date time

    var newDate = start.setMinutes(start.getMinutes() + 60);  // +

    //alert (newDate);

    Xrm.Page.getAttribute("scheduledend").setValue(newDate);

    Xrm.Page.getAttribute("scheduleddurationminutes").setValue(60);  // this is duration

    }

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fixing appointment time be default to 1hr from 30 min

    Pluggin assistance will also help me. Please help me.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fixing appointment time be default to 1hr from 30 min

    I have tried this code, do not seem to work, is anyone there to help me write the code to change the default duration for appointment inside activities from 30 minutes to 60 minutes by default;

    this is my code --

    function SetDuration() {

       alert("hit JS");

       // FORM_TYPE_CREATE = 1

       if (Xrm.Page.ui.getFormType() == 1) {

           var attribute = Xrm.Page.getAttribute(sdm);

           alert(attribute);

           if (attribute.getValue() == null) {

               attribute.setValue(new TimeRanges());

           }

           attribute.setValue(attribute.getValue().setHours(1, 0, 0));

       }

    }

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans