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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How un editable "Add lines" button in SalesLine

(0) ShareShare
ReportReport
Posted on by 117

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 .

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    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.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    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.

  • HARISH MEHRA Profile Picture
    117 on at

    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);
    
                }
            }
        }

  • GirishS Profile Picture
    27,843 Moderator on at

    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);
    
            }
            
        }

    Thanks,

    Girish S.

  • HARISH MEHRA Profile Picture
    117 on at

    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.

  • GirishS Profile Picture
    27,843 Moderator on at

    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.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    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.

  • HARISH MEHRA Profile Picture
    117 on at

    Hi ,

    Written the code provided but same result.

    Add product is editable.

    NOTE- Also written the code  on SalesLine form Datasource OnInitialized

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    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.

  • GirishS Profile Picture
    27,843 Moderator on at

    Have you debugged the code.?

    See what is the value of salesLine buffer/

    Thanks,

    Girish S.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 258 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans