Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)
Answered

get displayed view id in javascript

(0) ShareShare
ReportReport
Posted on by 135

Hi,

I need to get the (system) view id of the currently displaying View in javascript,

basically I want to set visibility of different ribbon buttons based on the view user has selected, I'm writing a js and use Ribbon Workbench to set visibility of the custom buttons based on this js and in the js function I need to know which View (user or system) is showing.

am I in a right path?

and can I get that guid?

*This post is locked for comments

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: get displayed view id in javascript

    Hi,

    This is unsupported. Think twice before use it.

    5102.9.png

    Javascript reference

    https://mahadeomatre.blogspot.my/2015/04/hide-ribbon-button-based-on-view.html

    remember change the function name.

  • Muhammad Naderi Profile Picture
    Muhammad Naderi 135 on at
    RE: get displayed view id in javascript

    well as far as unsupported methods, I already posted mine, perhaps i you post it as well it will be saved for future references bro

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: get displayed view id in javascript

    Hi,

    but it is unsupported , do you still want to use?

  • Muhammad Naderi Profile Picture
    Muhammad Naderi 135 on at
    RE: get displayed view id in javascript

    can you share the solution ?

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: get displayed view id in javascript

    Hi,

    i am able to generate it successfully but only name at this time and unsupported js also :(

    32421.8.png

    32421.8.png

  • Suggested answer
    Muhammad Naderi Profile Picture
    Muhammad Naderi 135 on at
    RE: get displayed view id in javascript

    actually this is the way I'm going but I was hopping that there was a supported method

    anyway this is the working js, for future reference

    var cv = document.querySelectorAll('[currentview]');

       if (cv != null && cv[0] != null) {

           var currViewId = cv[0].getAttribute("currentview");

           var currViewType = cv[0].getAttribute("currentviewtype");

       }

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: get displayed view id in javascript

    seems there is no such supported way you can get the view ID. You can try with accessing DOM.  Although this is not recommended by Microsoft.

    <a tabindex="0" title="Select a view" class="ms-crm-View-Name           ms-crm-View-Name-View-Lite" id="crmGrid_SavedNewQuerySelector" style="text-decoration: none; position: relative;" onclick="return false;" href="javascript:;" gridid="crmGrid"><span class="ms-crm-View-Name ms-crm-ViewSelector-title-associated-lite ms-crm-TextAutoEllipsis" currentviewtype="1039" quickfindquery="{8DF19B44-A073-40C3-9D6D-EE1355D8C4BA}" userownedview="{00000000-0000-0000-00AA-000010001003}" userselecteddefaultview="" defaultsavedqueryview="{6FC35112-D06B-E711-8103-000C29CBC14A}" currentview="{6FC35112-D06B-E711-8103-000C29CBC14A}">New Customers</span><span class="ms-crm-View-icon ms-crm-ViewSelector-dropdown-icon-associated-lite"><img class="ms-crm-View-icon-associated-lite ms-crm-ImageStrip-Dropdown_Arrow" alt="Select a view" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1886137834"></span></a></div>

    Let me know if this helps.

  • Muhammad Naderi Profile Picture
    Muhammad Naderi 135 on at
    RE: get displayed view id in javascript

    the post is to get the selected rows id

    what I need is to get selected view's id (eg, the "Open Invoices" view or "Closed Invoices" ...)

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: get displayed view id in javascript

    Hi,

    you can try to refer below post.

    community.dynamics.com/.../248073

  • Muhammad Naderi Profile Picture
    Muhammad Naderi 135 on at
    RE: get displayed view id in javascript

    Hi, I mean the entity home page view

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans