Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to hide sub-grid buttons in a quickview form?

(0) ShareShare
ReportReport
Posted on by 873

Hello,

I doubt that is possible but I am trying to find a way to hide "Add new & Add Existing" from the quick-view form of the sub-grid.
pastedimage1679857629249v1.png

If it is not possible, can we have logic that if the user is trying to create an entry from Table X throw an exception that he cannot add an entry from this table?

I would greatly appreciate it if you could provide an example.

Best regards,

EBMRay

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: How to hide sub-grid buttons in a quickview form?

    Hello Eiken ,

    The disadvantage is that it will hide both buttons from the entity itself (everywhere) and I don't want that. The main goal is only to hide it from a quick view form and from a specific entity.

    If this is not possible in RibbonWorkBench, can you show the alternative way of disabling the button from a sub-grid onLoad of the form?

    Awaiting your response.

    Best regards,

    EBMRay

  • Suggested answer
    Eiken Profile Picture
    Eiken on at
    RE: How to hide sub-grid buttons in a quickview form?

    Hi,

    It still works in sub-grid in a quick view.

    You need only remove the button on the selected entity, then all quick view which use this entity's sub-grid will hide the button.

    pastedimage1679989849708v1.png

    Now

    pastedimage1679989870443v2.png

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: How to hide sub-grid buttons in a quickview form?

    Hello Eiken ,

    Unfortunately, the sub-grid is in a quick view and that option won't work.

    As an alternative a JS would be needed to hide those two buttons on the sub-grid.

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: How to hide sub-grid buttons in a quickview form?

    Hello DAnny3211 ,

    I appreciate the steps provided.

    This first option will not work because it will disable add/add existing everywhere including the main entity, and I want to avoid that.

    I think the JS workaround will make it work since it will only disable the buttons on the same table.

    In the example provided, it will only disable the (Add Button). What will be the updated code to also disable the (Add Existing button)?

    Awaiting your response and will try it and get back to you.

    Best regards,

    EBMRay

  • Suggested answer
    Eiken Profile Picture
    Eiken on at
    RE: How to hide sub-grid buttons in a quickview form?

    Hi,

    You can hide button using ribbon work bench.

    Open Ribbon Workbench and select related Entity and then you will get 3 levels.(You need select Employee Rates here)

    Entity

    Subgrid

    Form.

    SO in Subgrid which button, you want to hide then right click and Hide.

    pastedimage1679972463708v1.png

    Then the Add button have been hiden.

    pastedimage1679972551048v2.png

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,274 Super User 2024 Season 1 on at
    RE: How to hide sub-grid buttons in a quickview form?

    hi

    It is not possible to hide "Add new & Add Existing" buttons from the quick view form of the sub-grid. However, you can disable the "Add new & Add Existing" buttons on the sub-grid itself so that users are not able to add new records to that sub-grid.

    To do this, follow the steps below:

    Open the form in the form editor and navigate to the sub-grid you want to modify.

    Click on the "Controls" tab and select the sub-grid control.

    In the "Properties" section, expand the "Behavior" section.

    Set the "Add new record" and "Add existing record" properties to "false".

    Alternatively, you can add a JavaScript function to disable these buttons based on a certain condition. For example, if you want to disable the "Add new" button when the user is trying to create an entry from Table X, you can use the following code:

    function disableAddNewButton() {

     var gridControl = Xrm.Page.getControl("yourSubGridControlName");

     var addButton = gridControl.getControl("addButton");

     addButton.setDisabled(true);

    }

    function checkForTableX() {

     var entityName = Xrm.Page.data.entity.getEntityName();

     if (entityName === "tablex") {

       disableAddNewButton();

     }

    }

    Xrm.Page.data.entity.addOnSave(checkForTableX);

    This code will disable the "Add new" button on the sub-grid when the user is trying to create a record from Table X. The addOnSave function is used to trigger the checkForTableX function whenever a record is saved on the form.

    DAniele

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! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans