Notifications
Announcements
No record found.
Hello all,
I create a customizaton form.
In this form, i want to enabled/disabled Delete Record (Alt F9) submenu of FILE menu (following image).
How to code with X++?
Alex
*This post is locked for comments
Hi Alex.
You need to set the "allow delete" property on your form data source to "NO"
Hi Alex,
You can write this code on the active method of your datasource where you want to toggle this property. So if your condition, where you want to allow delete is true, you can set the allowDelete property of the datasource as true.
In the below example if for example you want to allow delete if qty of purchline is less than 5 then write the below code in Active method of purchLine datasource:
if (purchLine.purchQty< 5)
{
purchLine_ds.allowDelete(true);
}
else
purchLine_ds.allowDelete(false);
You can also find many references in standard AX code on how to call this function.
Hope this helps,
Priyanka Agarwal
Hi Jonathan, Priyanka
Thank you so much!
Hi Alex. Please can you mark the solutions as verified
For the Document handing form even if I set the form only ds DocuRef AllowDelete == No, but the 'Delete Record' menuitem is still not disabled. How can I get access to this actual menuitem to set the flag myself through the Form init event?
If you mean like a button (menu item) then you can set AutoDeclaration property on this button (design -> your_button -> properties) to yes and use button.enabled(false) wherever you want inside the scope of this form. Additional information about form control properties can be found here: msdn.microsoft.com/.../aa845161.aspx
Hi
Access to these buttons should be controlled by standard AX behaviour. I.E. Based on whether the datasource allows for deletion or not. Trying to customise this will cause problems across the board.
Setting this on the datasource on your form in the AOT is just controlling the default behaviour when the form is opened. Take a look in the doReSearch method of this form and you will see that the deletion is reenable/disabled based on other rules. If you want to never allow deletion on this form add the line docuRef_ds.allowDelete(false); to the bottom of this method to overwrite any standard rules.
same option delete record enable/disable option on attachment form on Account payable -> Lines -> Attachment ->File -> Delete Record (enable) please reply if anyone know about this issue.
Hi Waqas qADIR,
can you explain your issue in a new thread?
actually we not given any rights to user to delete attachment file but they can delete it from Delete Record which is attach in Account payable voucher lines attachment.even our Consultant have no idea about this option to hide this button from File submenu Delete Record
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 Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2