Moved from Dynamics 365 General Forum, because the code looks like X++.
If your goal is preventing users from creating and deleting lines, your approach is wrong, because users don't have to use these buttons. Instead, you should set the data source to disallow creates and deletes. For example:
SalesLine_ds.allowDelete(false);
Also note that sometimes is better to keep the option enabled and stop the process in validation (e.g. valiidateDelete()), because then you can tell us why it's not allowed. If they just see a disabled button, they may have no idea why.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 1,841
André Arnaud de Cal... 836 Super User 2025 Season 2
Sohaib Cheema 531 User Group Leader