Hello Experts,
For un editable "Add line" button in SalesLine we use --> SalesLine.allowCreate(false) .What we use for making un editable "Add lines" button .
Hi Harish,
You need to write code to disable the button. Auto declaration property of the control is already set to yes.
You can write COC for active method of form DataSource and disable the button like below.
ButtonLineQuickQuote.enabled(false);
Thanks,
Girish S.
Hi, It's a form button control which you can disable by writing code on form init method, if you want to disable it always. You can use CoC or event handler.
Hi Giris/Mohit,
My code is working for "Add Lines" in Sales Line but not working for "Add Products".I have written the below code -
[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Activated)] public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e) { FormDataSource salesLine_ds = sender; SalesLine salesLine = salesLine_ds.cursor(); SalesLine sL; FormRun element = sender.formRun(); FormControl ButtonLineQuickQuote = element.design(0).controlName("ButtonLineQuickQuote"); FormControl RetailAddItemMenuItem = element.design(0).controlName("RetailAddItemMenuItem"); while select sL where sL.SalesId == salesLine.SalesId { if ( sL.PickingInProgress_CAP == NoYes::Yes) { ButtonLineQuickQuote.enabled(false); RetailAddItemMenuItem.enabled(false); RetailAddItemMenuItem.allowEdit(false); //SalesLine_ds.allowedit(false); SalesLine_ds.allowDelete(false); SalesLine_ds.allowCreate(false); } } }
No need of adding while select statement inside the active method. Active method will be called when the cursor moves over the another record.
[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Activated)] public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e) { FormDataSource salesLine_ds = sender; SalesLine salesLine = salesLine_ds.cursor(); SalesLine sL; FormRun element = sender.formRun(); FormControl ButtonLineQuickQuote = element.design(0).controlName("ButtonLineQuickQuote"); FormControl RetailAddItemMenuItem = element.design(0).controlName("RetailAddItemMenuItem"); if (salesLine.PickingInProgress_CAP == NoYes::Yes) { ButtonLineQuickQuote.enabled(false); RetailAddItemMenuItem.enabled(false); RetailAddItemMenuItem.allowEdit(false); //SalesLine_ds.allowedit(false); SalesLine_ds.allowDelete(false); SalesLine_ds.allowCreate(false); } }
Hi Girish,
While statement I used for checking some condition on each line.
But here the thing is Add Products is editable after writing this code.
See you need to understand one thing. Adding while select statement in the active method affects the performance of the form.
For your scenario while select is needed. active method will get called each time when the records are changes, so it will check the condition each time when cursor is moved to another record.
Active method will be called whenever user select a Sales order line, so your code will run every time trying to make these buttons non editable (which are already non editable). Code will work in active method as well but its better to add in SalesLine form Datasource OnInitialized event.
Please use code suggested by Girish and let us know if still any issues.
Hi ,
Written the code provided but same result.
Add product is editable.
NOTE- Also written the code on SalesLine form Datasource OnInitialized
Have you debugged the code? Check if RetailAddItemMenuItem is initialized correctly.
Also If you want to enable/disable buttons based on data in SalesLine then Active method is correct.
Have you debugged the code.?
See what is the value of salesLine buffer/
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 Pallavi Phade as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
André Arnaud de Cal... 756 Super User 2025 Season 2
CA Neeraj Kumar 678
Martin Dráb 526 Most Valuable Professional