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)

Autoset Date on Quick Create Form

(0) ShareShare
ReportReport
Posted on by 225

Hello,

I am trying to set a date field on the Phone Call quick create form but I cannot get the onLoad to work for this as in the web based forms.  My code is

Is there a way I can get the onLoad event to work? It seems the onChange event is working.

Thanks

*This post is locked for comments

I have the same question (0)
  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    can you share your code?

  • Jerry P. Profile Picture
    225 on at

    I have something like this.

    function SetTodaysDateOnLoad(executionContext)

    {

    var formContext = executionContext.getFormContext();

    if  (formContext .context.client.getClient() == "Mobile")// &&  Xrm.Utility.getGlobalContext.getAttribute("scheduledend").getValue()== null) //commented out for eliminate this piece at this time

    {

    formContext .getAttribute("scheduledend").setValue(new Date()); //Sets today's date

    }

    //formContext .getAttribute("scheduledend").setValue(Date.now());

    }

    The event handler only has the onChange event option.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    if  (formContext .context.client.getClient() == "Mobile") <---

    you put the checking , when the client is using Mobile, then only go into your logic, if you wan to achieve in web based, put another checking or else statement.

    Futhermore, register this function in onload event too.

  • Jerry P. Profile Picture
    225 on at

    Hello,

    I did have the additional client check ion there but removed it, How do I add the onLoad event for this?  

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    open your quick create form via customization, click form properties. Then you can see from there.

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

    Hi Jerry ,

    Ideally it  should work with setting new Date(). 

    However I would request you please try with this  -

    function SetTodaysDateOnLoad(executionContext)
    {   
        var todaydate = new Date();
        var today = todaydate.getFullYear() + '/' + (todaydate.getMonth() + 1) + '/' + todaydate.getDate();
        var formContext = executionContext.getFormContext();
        if  (formContext.context.client.getClient() == "Mobile")
        {
            formContext.getAttribute("scheduledend").setValue(today); // You can also try to set directly todaydate
        }
        else
        {
            // Do something here if not mobile client 
        }
    }
  • Jerry P. Profile Picture
    225 on at

    Yes, that is where it was. I was looking under the event handler on the field properties and not the form properties.

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