Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

onLoad Event Handler Not Working on Mobile Devices

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

  • Jerry P. Profile Picture
    Jerry P. 225 on at
    RE: onLoad Event Handler Not Working on Mobile Devices

    That did it. Thank you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: onLoad Event Handler Not Working on Mobile Devices

    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 ..

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: onLoad Event Handler Not Working on Mobile Devices

    Hi Jerry,

    Try using the code below.

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

    Hope this helps.

  • Jerry P. Profile Picture
    Jerry P. 225 on at
    RE: onLoad Event Handler Not Working on Mobile Devices

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

    }

    }

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: onLoad Event Handler Not Working on Mobile Devices

    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.

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,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