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 :
Finance | Project Operations, Human Resources, ...
Answered

How un editable "Add lines" button in SalesLine

(0) ShareShare
ReportReport
Posted on by 113

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,825 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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,563 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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
    113 on at
    RE: How un editable "Add lines" button in SalesLine

    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,825 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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
    113 on at
    RE: How un editable "Add lines" button in SalesLine

    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,825 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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,563 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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
    113 on at
    RE: How un editable "Add lines" button in SalesLine

    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,563 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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,825 Moderator on at
    RE: How un editable "Add lines" button in SalesLine

    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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 756 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 678

#3
Martin Dráb Profile Picture

Martin Dráb 526 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans