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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Show/Hide button depending on view

(0) ShareShare
ReportReport
Posted on by

Hi, All.

I have new custom entity with two views - for active records & inactive records.

How I can hide button "Active" in view for active records?  And hide button "Inactive" in view for inactive records? I understand what I can do it with javascript... But how?

Id for both views I see.

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Nataly,

    Have you tried this?

    practical-crm.blogspot.com/.../ribbon-get-view-id-context-sensitive.html

    micodes.blogspot.com/.../how-to-pass-current-view-id-to-custom.html

    It's kind of for CRM 2011, I haven't tried this for higher version.

    I hope this can help.

    Thank you.

  • Community Member Profile Picture
    on at

    Thanks, but doesn't work. Both...

    This code:

     var el = getElementsByAttribute("span", "currentview"); 


    in general has error....

  • Community Member Profile Picture
    on at

    Sorry, not error, but return "undefined".

  • Community Member Profile Picture
    on at

    I don't think you can do that easily. What you might consider is removing (hiding) them both, then adding your own custom button "Change status" which calls a script that checks the current status of the selected record(s) and flips it, so it works as an Activate and Deactivate button combined.

  • Community Member Profile Picture
    on at

    I change solution from micodes.blogspot.com/.../how-to-pass-current-view-id-to-custom.html a little.

    Was 

    var el = getElementsByAttribute("span", "currentview");  
    var viewId = el[0].id;

    Now, in el - already Id for current view, but in format "{....guid....}".

    I used 

    var viewId2 = el.toString().replace("{", "").replace("}", "");
    

    My code for ribbon:

    var ShowHideActiveInactiveInView = function (viewId) {
            var selectedViewId = document.getElementsByTagName("span");
    
            var el = getElementsByAttribute("span", "currentview");
            var viewId2 = el.toString().replace("{", "").replace("}", "");
            
            if (viewId2 == viewId) {
                return true;
            }
            else {
                return false;
            }
        }


    It's works.

    Thanks!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans