Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

how to call javascript on ms crm home page onload ?

(0) ShareShare
ReportReport
Posted on by 20

i want to call javascript function on ms crm home page load .

like , i want to display a message , hide a button etc 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to call javascript on ms crm home page onload ?

    I have the same issue, can you share more details about how to use Enable/Display Rule ?

  • Suggested answer
    BharatPremji Profile Picture
    BharatPremji 2,485 on at
    RE: how to call javascript on ms crm home page onload ?

    Hi Raju,

    I have done something similar in the past to set up a re-direct from a dashboard.

    Create a new HTML webresource and put the following code into the Source tab:

    <html><head><meta charset="utf-8"></head>
    <body style="-ms-word-wrap: break-word;">
    <script type="text/javascript">
    function redir() {
    alert("This system is no longer active. You will now be redirected");
    window.top.location.href="https://google.com";
    }
    redir();
    </script>
    <br></body></html>

    You'll need to replace the redir() function with the alert you want.

    Then simply add the HTMl resource as a component on the dashboard

    Bharat

  • Raju Bathula Profile Picture
    Raju Bathula 20 on at
    RE: how to call javascript on ms crm home page onload ?

    thanks for your reply

    my actual requirement is Display a notificationbar in sales activity dashboard onload

    can you suggest me for that ...

  • Raju Bathula Profile Picture
    Raju Bathula 20 on at
    RE: how to call javascript on ms crm home page onload ?

    ok, thanks for your reply

    my actual requirement is Display a notificationbar in sales activity dashboard onload

    can you suggest me for that ...

  • Suggested answer
    JayeshAC Profile Picture
    JayeshAC 1,157 on at
    RE: how to call javascript on ms crm home page onload ?

    Hi Raju,

    A . Which kind of message you want to display onload of form?

    For error, information or warning message, you can use below code.

    1. Xrm.Page.ui.setFormNotification("This is an INFORMATION notification.", "INFORMATION") 

    2. Xrm.Page.ui.setFormNotification("This is a WARNING notification. ", "WARNING") 
    3. Xrm.Page.ui.setFormNotification("This is an ERROR notification. ", "EROR")
    B. what do you mean with HomePage? Is it Form or HomeGrid?
    For Form, you can use onload event of form to run your javascript
    For HomeGrid, you can write your javascript in button Enable/Display rule. it will show your message and hide the button according the conditions you have mentioned in that script.
    Regards,
    Jayesh
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to call javascript on ms crm home page onload ?

    What do you mean by home page? Starter page can be different for different users.

  • Verified answer
    Irene Chng Profile Picture
    Irene Chng 40 on at
    RE: how to call javascript on ms crm home page onload ?

    you can use this method to display the message.

    Xrm.Page.ui.setFormNotification(message, level, uniqueId);

    Parameter of Level defines how the message will be displayed.

    • WARNING : Notification will use the system warning icon.
    • INFO : Notification will use the system info icon.
    • ERROR : Notification will use the system error icon.

    What kind of button do you want to hide? Custom or OOB button?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans