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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Disable delete button in Sales TableListPage Form

(0) ShareShare
ReportReport
Posted on by 436

Hi experts,

I want to disable delete button in Sale TableListPage form based on one checkbox condition.

Please suggest me how to achieve the same. 

Thanks

Sona Jee

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    This code will disable the button: SalesTable_ds.allowDelete(false);

    Where to put it depends on where your checkbox is. Is the checkbox some general parameter? Or is it a field on SalesTable?

    If it's a parameter, you should place the code in the init method of the form.

    If it's a field in SalesTable, you need to place the code in the active method of the SalesTable data source, and adjust it a bit:

    SalesTable_ds.allowDelete(SalesTable.MyCheckBox); // This will allow editing if checkbox is Yes.

  • Sona Jee Profile Picture
    436 on at

    Hi Nikolaos,

    I have a checkbox parameter in Account receivable parameter.

    I have written the code in OnActivated event handler of sales table but its not worked.

    Please suggest the right way.

    Thanks

    Sona Jee

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Hi,

    did you check the suggestion in my previous post? Seems you did not yet try it. Please let us know how it goes after trying it. And please share your code if you need more assistance.

    Thanks!

  • Sona Jee Profile Picture
    436 on at

    Hi,

    I have tried by this but not working:

     [FormDataSourceEventHandler(formDataSourceStr(SalesTableListPage, SalesTable), FormDataSourceEventType::Initialized)]
            public static void SalesTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
            {
                SalesTable      salesTable      = sender.cursor();
                FormDataSource  salesTable_ds   = sender.formRun().dataSource("SalesTable");
                FormRun         element         = sender.formRun();
    
                if(Checkbox == NoYes::Yes)
                {
                    salesTable_ds.allowDelete(false);
                }
                else
                {
                    salesTable_ds.allowDelete(true);
                }
            }

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    So you chose to add your code in the init method of the data source, instead of the init method of the form.

    That should work, too.

    Did you notice that you have the data source available in "sender", so you don't have to go through sender.formRun().dataSource("SalesTable")?

    Could you describe in more detail what you mean by "not working"? Did you debug it? Please do, and share the findings with us. What is the "Checkbox"? Is that the value you get from your parameters table?

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Sona Jee,

    What path did you say the Delete button? System-defined?

    docs.microsoft.com/.../system-defined-buttons

    Note that if the data sources still let the user create and delete records, the keyboard shortcuts will continue to work even if the system buttons aren't visible.

    -

    If not,You can try this:

    if( CONDITION)
      {
          YourButtonName.enabled(true);
      }
      else
      {
          YourButtonName.enabled(false);
      }
    
    

  • Sona Jee Profile Picture
    436 on at

    Hi Blue Wang,

    Its system defined button.

    Here two forms are in process SalestableListPage and SalesTable.

    I have written form init method for SalestableListPage its working but for SalesTable form i have written formdatasource active ,its not worked for me.

    Please suggest

    Thanks

    Sona Jee

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Hi Sona, did you still have a chance to try my suggestion and implement your code in the init method of the form? Also now you say that your code works in SalesTableListPage, that's good! For SalesTable, I would once again be happy to see your code so that we could spot any issues in it. But the mechanism is the same on all forms.

  • Sona Jee Profile Picture
    436 on at

    Hi,

    This code is for SalesTableListPage:Its working for me

    [FormEventHandler(formStr(SalesTableListPage), FormEventType::Initialized)]
    public static void SalesTableListPage_OnInitialized(xFormRun sender, FormEventArgs e)
    {

    FormDataSource salesTable_ds = sender.dataSource('SalesTable');

    if(Checkbox == NoYes::Yes)
    {
    salesTable_ds.allowDelete(false);
    }
    else
    {
    salesTable_ds.allowDelete(true);
    }

    }

    This code is for sales table:not working

    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
    SalesTable salesTable = sender.cursor();
    FormDataSource salesTable_ds = sender.formRun().dataSource("SalesTable");
    FormRun element = sender.formRun();

    if(Checkbox == NoYes::Yes)
    {
    salesTable_ds.allowDelete(false);
    }
    else
    {
    salesTable_ds.allowDelete(true);
    }
    }

    Thanks

    Sona

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Ok. And could you please try the suggestion of putting your method in the init method/event of the form? I don't know how I could help you because you seem to ignore my suggestions.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March 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... 632 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 624

#3
CP04-islander Profile Picture

CP04-islander 301

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans