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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

validate delete code

(0) ShareShare
ReportReport
Posted on by 131
I have extended a form to write validation on timesheet delete line in the below event handler:
what should i write to prevent delete if enum value is yes.
 
 [FormControlEventHandler(formControlStr(TSTimesheetEntry, DeleteLine), FormControlEventType::Clicked)]
    public static void DeleteLine_OnClicked(FormControl sender, FormControlEventArgs e)
    {
         FormDataSource    Table_ds   =  sender.formRun().dataSource(formDataSourceStr(form, Table));
        Table record = Table_ds.cursor() as Table;
        if (record.field == NoYes::Yes)
        {
               
            checkFailed(/PTO line updation is not allowed/);
           
               
        }
 

       
    }
pls suggest.
        
I have the same question (0)
  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at
    Hi Ayushii,
     
    I think adding clicked eventHandler for the DeleteLine button won't work here. 
    It's better to add the validation at table level of TsTimesheetLine.
    Add your logic on the ValidateDelete method on the table. You can use COC or event handlers.
     
    Thanks,
    Girish S.
  • Suggested answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Clicked is a wrong event for validation, it's too late there and pressing a button isn't the only way how to delete a record.
     
    Instead, override validateDelete() method of the table or handle its ValidatingDelete event.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar 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... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans