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

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,825 Moderator on at
    validate delete code
    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
    236,974 Most Valuable Professional on at
    validate delete code
    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…

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... 701 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 588 Most Valuable Professional

#3
Sumit Singh Profile Picture

Sumit Singh 544

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans