Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Set focus on time selection area of date and time field after selecting date via date time picker?

Posted on by 1,579

I have a Dynamics 365 V9 Implementation and need to change the behavior of both the scheduledstart (Start Time) field and scheduledend (End Time) fields.

 

The out of box behavior is not suitable for end users that will be entering hundreds to thousands of appointments daily.

 

The two fields referenced above are date and time fields as shown below.

 

7573.SCHEDULEDSTART.png

 

When users click on the Start Time field, and set the Date via the date time picker, focus immediately leaves the field and goes out to the browser screen forcing the user to move their mouse and click back into the field and then set the time. This can be seen at the 7 second mark and 17 second mark in the video clip below.

 


 

The required behavior is for the cursor to immediately enter the time section after the user selects the date via the date time picker.

 

Normally, I would snap a function onto the date field and have it set focus in the time field on change.

 

The problem is that this is a single field so the usual way of handling it is a non-starter.

 

Can anyone recommend a way of handling this? What have others done to achieve the desired behavior I described with this type of field?

 

 

 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set focus on time selection area of date and time field after selecting date via date time picker?

    Hi, I have the same problem. Once the Date is entered the user needs the focus to automatically move to the time portion of the Date and Time Control. Since the Date and Time is part of the same control, using setFocus() will only set the cursor on the date. Does anyone have a solution for this?

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Set focus on time selection area of date and time field after selecting date via date time picker?

    Hi,

    I am not sure that you  will get time control separately . But applying my code you can achieve at least control  focus . See the video  after applying the set-focus.

    www.youtube.com/watch

  • ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Set focus on time selection area of date and time field after selecting date via date time picker?

    I was able to try this, and it doesn't work.

    I adjusted the timeout from 500 to 100, then 300, then 1000 and nothing.

    It's as if the code isn't even there as shown below. There are no errors, but the code isn't working at all. 

    Focus doesn't jump from the date portion of the control to the time portion of the control.

    The desired behaviour is shown in the two screen shots below.

    C12.png

    The actual behaviour shown in the video below does not resemble the desired objective at all. 

    Is there a way to interact with the fieldname.control name since two controls are part of a single field similar to the desired type of command below?

    formContext.getControl(fieldname.controlname).setfocus()

  • ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Set focus on time selection area of date and time field after selecting date via date time picker?

    Thanks for the novel approach! That's not something I would have thought of. I will try that and see if that solves my issue.  In the interest of time, I'll mark it as verified. If that changes or if there is something preventing this from being applicable, I will reply with appropriate details.  My goal is to get the cursor from the date control portion of the field to the time control portion of the same field once the date has been selected. Thanks for lighting up my pathway. I'll test that out and see if it works. 

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Set focus on time selection area of date and time field after selecting date via date time picker?

    Hi ,

    Its a problem , I agreed with you. I tried to make setfocus  inside some time out , for me its now focusing correctly .

    Try with this -

            // attach the method start date onchange
            function onChangescheduledstart()
            {
                window.setTimeout(function(){
                    Xrm.Page.getControl("scheduledstart").setFocus();
                },500);
                
            }
    
            //Attach the method enddate onchange
            function onChangesscheduledend()
            {
                window.setTimeout(function(){
                    Xrm.Page.getControl("scheduledend").setFocus();
                },500);
               
            }

    FYI ,I found by default this datetime section is locked , so you need to unlock from section properties and then attach above onchange method of the fields.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans