Skip to main content
Dynamics 365 general forum
Suggested answer

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

editSubscribe (0) ShareShare
ReportReport
Posted on by 863

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 863 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 863 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 863 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,180 Super User 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

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans