Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Hide button on a Ribbon

Posted on by 308

Hello all, I have a custom entity where I  added a subgrid in main form, and I have also added the custom button on the ribbon. My requirement is My custom button should be shown visible only there are records in the subgrids.??? Anyone know how can I achieve this? First I will apply the FormStateRule so custom button is available only for existing form because once I saved the form then only I can add data in subgrid, and my requirement is the custom button should only be shown when there is data in subgrid.

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Hide button on a Ribbon

    Hello Ishan ,

    In my opinion you need to implement enable rule with custom javascript in that case. Register one java script function where you need to retrieve the related data using web API for subgrid using the entity id of the parent record. If any related data found then return true other wise return false.. Here is the step -

    function HideRibbonButton() {  
    
       var entityid =Xrm.Page.data.entity.getId();  //EntityId to retrieve the subgrid data
    
    //Write web API to retrieve subgrid entity data where parententityid =entityid 
    //Retrieve the result 
       if (result.count > 0) {  
    
           return true;
    
       }
    
       else {
    
           return false;
    
       }
    
    }



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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

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