Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

How to Set Personal View as Default View using Javascript not via UI

Posted on by Microsoft Employee

I want to make my personal view as default view using javascript not through UI.

Categories:
  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: How to Set Personal View as Default View using Javascript not via UI

    Good day Rohit,

    Thanks for your explanation.

    I found on the Internet and I didn't find any information about setting default view by JS code, as you konw, there is no way for us to add js code to homepage to do some operations. I only found that we could set default view by editing solution xml files.

    community379.png

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/customize-entity-views

    Hope it helps.

    Best Regards,

    Leo

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Set Personal View as Default View using Javascript not via UI

    Hi Leo,

    Let me precise my query.

    As we know we can set any of our personal view as default from Advanced Find screen under SAVED VIEWS by clicking Set As Default View button as shown in below image:

    6036.img.png

    Lets assume I have View Id. I want achieve this using JavaScript code.

    I just want to know what entity or attributes are changed on click of Set As Default View button so that I can also achieve this using JavaScript .

    Regards,

    Rohit Singla

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: How to Set Personal View as Default View using Javascript not via UI

    Hi Rohit,

    Sorry that there is no way to do this. As you know, we could only add js to form but we could not add js to homepage :-(.

    So we could only use OOB way to do this with UI.

    Best Regards,

    Leo

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Set Personal View as Default View using Javascript not via UI

    Hi Leo,

    Thanks for the reply :)

    This would not fulfill my requirement.

    The code you have written will work on form but I have to set default view for the Entity Home page grid i.e whenever user enters to the entity the view which is shown to the user.

    I need to change the view on  entity home page grid.

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: How to Set Personal View as Default View using Javascript not via UI

    Hi partner,

    1.You should get your view id with Advance Find.

    2.You could use this code to set your view as default view.

    function setDefaultViewSample(executionContext) {
        var formContext = executionContext.getFormContext();
        formContext.getControl("primarycontactid").setDefaultView("{00000000-0000-0000-00AA-000010001003}");
    }


    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/controls/setdefaultview

    Hope it helps.

    Best Regards,

    Leo

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

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