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)

onLoad Event Handler Not Working on Mobile Devices

(0) ShareShare
ReportReport
Posted on by 225

I have created an olLoad event for the Sales Activities Date of Activity. This is working when using the web client but not working when on a mobile device, iPad/Windows mobile. What need to be done to get this to work on mobile devices?  

The onLoad event is:

function SetTodaysDateOnLoad(){

if (Xrm.Page.getAttribute("scheduledend").getValue()== null){
Xrm.Page.getAttribute("scheduledend").setValue(Date.now());

}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Jerry,

    There are certain differences when writing scripts in dynamics CRM for tablets and phones.

    Try using the code below.

    See: https://msdn.microsoft.com/en-in/library/dn481572.aspx

    Hope this helps.

  • Jerry P. Profile Picture
    225 on at

    Hi Nithya,

    I am a little closer, I followed the msdn article and have an alert working when on a mobile device but no date is getting set.  Do I need to use another way to setValue of a field when on mobile?

    My code for this is:

    function SetTodaysDateOnLoad()

    {

    if  (Xrm.Page.context.client.getClient() == "Mobile" &&  Xrm.Page.getAttribute("scheduledend").getValue()== null)

    {

    Xrm.Page.getAttribute("scheduledend").setValue(Date.now()); //This does not work, date not getting set

    //alert("You are creating a new sales activity"); //This alert works

    }

    else

    {

    if (Xrm.Page.getAttribute("scheduledend").getValue()== null)

    Xrm.Page.getAttribute("scheduledend").setValue(Date.now());

    }

    }

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Jerry,

    Try using the code below.

    Xrm.Page.getAttribute("scheduledend").setValue(new Date());  // Set the Date field to Today

    Hope this helps.

  • Community Member Profile Picture
    on at

    Hi Jerry,

    I'm using same JS codes in web that what I'm using in mobile, I just made the following change :-

    stackoverflow.com/.../javascript-for-crm-2016-phones

    This is was the only issue that making my codes not working in mobile.

    I really not sure that going to help you, but I'm trying to help you as much I can.

    Best Regards ..

  • Jerry P. Profile Picture
    225 on at

    That did it. Thank you.

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