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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?

(5) ShareShare
ReportReport
Posted on by 1,115

Hi everyone,

I have created a custom Card page with a subform, and both are editable. The subform currently shows the standard New and Delete action buttons.

Here’s what I want to achieve:

  • When the Activate Boolean on the Card page is turned ON, the New and Delete buttons on the subform should be disabled or hidden.
  • When Activate is turned OFF, these buttons should be enabled or visible again.

Currently, I’ve added validation in the OnInsert(), OnModify(), and OnDelete() triggers based on the Card page’s Activate Boolean.

However, since the InsertAllowed and ModifyAllowed properties only accept true or false values (and not variables), I don’t think this can be controlled dynamically through AL code.

Is there a recommended approach or best practice to handle this kind of behavior?

Thanks in advance!

 

I have the same question (0)
  • Verified answer
    Pallavi Phade Profile Picture
    2,658 on at
    Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?
    Namaste @Aman Kakkar
     
    Yes  i agree with you , you cannot set conditional property on new and Delete button 
     
    But I can suggest below ad this should work.
     
    1) create one subform pages and set insert , Delete properties to False 
    2) Create second Subform page and set insert delete properties to True
    3) In Main card , Page you set the visibility on Subform Based on Active Button PRoperty .
    4) IF active Button is True page 2 subform should be visible , Else Page 1 should be True. 
     
    IF you feel this helped , Please mark as "Verified"
     
    Regards
    Pallavi Phade 
  • Verified answer
    YUN ZHU Profile Picture
    93,874 Super User 2025 Season 2 on at
    Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?
    Hi, As far as I know, there is no solution at this time. You can submit this idea to Microsoft.
    Missing a feature? Post or vote for ideas on: aka.ms/BCIdeas
     
    PS:
    Dynamics 365 Business Central: How to hide/disable New, Edit (Edit List), and Delete actions on the page
     
    Thanks.
    ZHU
  • Suggested answer
    Rishabh Kanaskar Profile Picture
    5,474 on at
    Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?
    Hi,

    You can’t toggle InsertAllowed / DeleteAllowed at runtime because they’re static properties. The common workaround is:
    > Keep the properties set to true.
    > Control the behavior in the OnInsert/OnDelete triggers (as you already do) to block actions when Activate = true.
    > If you also want to hide/disable the buttons in the UI, use Visible/Enabled property on the page actions and bind them to a Boolean variable that you recalc in OnAfterGetRecord (based on the parent’s Activate flag).
     
    Best practice:
    > Validate in table triggers to ensure business rules.
    > Use variables + Visible/Enabled in page actions if you want to dynamically change button availability.
    That way you enforce rules at both data and UI levels.
     
    Thanks
    Rishabh
  • Aman Kakkar Profile Picture
    1,115 on at
    Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?
     
    If your reply was an AI-generated answer, please consider adding a short disclaimer so readers understand it might not be fully validated. And if it’s your own response, I’d suggest double-checking the answer in a test page — this area can be a bit tricky in AL.
     
    Just to clarify a couple of points:

    – The Visible property cannot be changed dynamically in the OnAfterGetRecord trigger. It can only be set or modified during the OnOpenPage trigger, as it’s evaluated when the page loads, not per record refresh.

    – Also, the New and Delete actions on a subform are not standard action buttons that can be shown or hidden using a Boolean. I don’t think I can even add code for New or delete action button based on Boolean when I do not have direct access to it?
  • Rishabh Kanaskar Profile Picture
    5,474 on at
    Dynamically disable New and Delete actions on a subform based on a Boolean field in the Card page?
     
    Thanks for the feedback! My original answer focused on the recommended approach when you need dynamic control over insert/delete behavior.
    > InsertAllowed and DeleteAllowed are static and can’t be toggled at runtime.
    > The usual workaround is to enforce business rules in table triggers and, if UI control is needed, use custom actions with Visible/Enabled bound to variables.
    > You’re correct that the system-generated New/Delete buttons can’t be dynamically hidden, and I should have clarified that my suggestion applies to custom actions, not the built-in ones. I also didn’t test this on a test page before posting.
     
    Appreciate the discussion, it helps make the solution clearer for everyone!

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,225

#2
Sumit Singh Profile Picture

Sumit Singh 2,123

#3
YUN ZHU Profile Picture

YUN ZHU 1,813 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans