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

validate delete code

(0) ShareShare
ReportReport
Posted on by 135
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.
        
  • Verified answer
    GirishS Profile Picture
    27,843 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
    240,961 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

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 August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 555 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU10121822-0 Profile Picture

CU10121822-0 378

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans