web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by 1,589

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

I have the same question (0)
  • gdas Profile Picture
    50,091 Moderator on at

    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.

  • ACECORP Profile Picture
    1,589 on at

    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. 

  • ACECORP Profile Picture
    1,589 on at

    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()

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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

  • Community Member Profile Picture
    on at

    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?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans