Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

FormControlEventHandler - How to call the form method (PurchEditLines)?

(1) ShareShare
ReportReport
Posted on by 731
Hello,
 
Using FormControlEventHandler, do I need to call the form method. I need to call the PurchEditLines.purchFormLetter(). How can I do this?
 
[FormControlEventHandler(formControlStr(PurchEditLines, OK), FormControlEventType::Clicked)]
    public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormRun formRun = sender.formRun();
        FormDataSource purchparmtable_ds = sender.formRun().dataSource(/PurchParmTable/);
        purchparmtable purchparmtable = purchparmtable_ds.cursor();
   
        // PurchFormLetter purchFormLetter =
 
        // TODO
     }
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,433 Most Valuable Professional on at
    FormControlEventHandler - How to call the form method (PurchEditLines)?
    Trying to put business logic to clicked() is usually a bad approach and it's indeed the case here.
     
    The OK button is a command button. It has no code in clicked(); the F&O kernel executes the command, which is closing the form. Then kernel executes a few form methods like canClose() and closeOK() (you can see existing business logic of PurchEditLines form there). Therefore you should create an extension of PurchEditLines form and extend a method like closeOK() with CoC. And there you can simply refer to purchFormLetter by name.
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    FormControlEventHandler - How to call the form method (PurchEditLines)?
    Hi Shooowtek,
     
    Is this method in form level?
    If yes, then you already defined formRun which is the form for your control.
    So would formRum.purchFormLetter() work?
     
    Thanks,
    Layan Jweihan

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans