Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

(0) ShareShare
ReportReport
Posted on by 110

Hi ,

I want to fetch view name on clicking of ribbon button . for eg . below i have opened Contacts in Dynamics 365 . By default it opens default view i.e "My Active Contacts" .

pastedimage1579663791869v2.png

So when i click on New button in this view then i want to run some custom javascript where i want to fetch this view name "My Active Contacts". As based on view name , i want to open different form as per each view.

So i tried by follow below mentioned blog but this javascript throws error when running .

Error :- object doesn't support property or method 'get_viewtitle'

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

Can anybody help me on this . How can i do it ?

Thanks

  • RE: How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

    Thanks , my issue sorted out.

  • Verified answer
    meelamri Profile Picture
    meelamri 13,212 User Group Leader on at
    RE: How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

    Hello Sumit Thakran,

    The method proposed on the blog does not work on UCI. I found an alternative that works on UCI but is not supported. The Basic Idea is to find the viewId.

    in your JS, use this: Xrm._page.getUrl(), the result would be something like:

    use this sample code to get the viewId:

    var urlParams = new URLSearchParams(Xrm._page.getUrl());
    var viewId = urlParams.get("viewid").replace("{","").replace("}","")
    
    console.log("viewId: "   viewId)
    /*
    viewId: 61273827-328E-E011-95AE-00155D9CFA03
    */

    hope this helps,

    Mehdi

  • Gilmeyer Profile Picture
    Gilmeyer on at
    RE: How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

    Hi,

    There is not a supported way to achieve that.

    Thanks

  • RE: How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

    Hi Gimeyer,

    i even tried code given in comments section of article but its not working.

    Below is comment section code :-

    selectedCtrl.getCurrentView(): Xrm.LookupObject

    entityType: "savedquery"

    id: "{00000000-0000-0000-00AA-000010001001}"

    name: "999.exampleView"

    __proto__: Object

    Nothing happens when i add this code . Can you help whats wrong in code

    Thanks

  • Suggested answer
    Gilmeyer Profile Picture
    Gilmeyer on at
    RE: How can i fetch current view name after clicking on Ribbon Button in Dynamics 365

    Hi,

    There is no supported way to achieve that.

    However, in the comments section of the referred article they explain which method should be used for D365.

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…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans