web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    are you referring to subgrid view or Entity homepage view?

  • Muhammad Naderi Profile Picture
    135 on at

    Hi, I mean the entity home page view

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    you can try to refer below post.

    community.dynamics.com/.../248073

  • Muhammad Naderi Profile Picture
    135 on at

    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
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • Suggested answer
    Muhammad Naderi Profile Picture
    135 on at

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

       }

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

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

    32421.8.png

    32421.8.png

  • Muhammad Naderi Profile Picture
    135 on at

    can you share the solution ?

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

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

  • Muhammad Naderi Profile Picture
    135 on at

    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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans