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, ...
Suggested Answer

How to call a form button clicked coc method in another form button clicked method

(1) ShareShare
ReportReport
Posted on by 336
Hi All,

I am implementing an validation logic for business scenario, where I have 2 button controls both are customized,
 
1.I had written coc clicked method for 'validate' button of 'whsloadplanninglistpage' form and also written coc clicked method for 'product receipt' button of 'whsloadtable' form.
2.I am trying to call the 'validate' button coc clicked method in 'product receipt' button coc clicked method before super call.
 
[ExtensionOf(formControlStr(WHSLoadTable,btnProductReceipt))]
final class WHSLoadTable_Extension
{
    void  clicked()
    {
        FormControl formButtonControl = any2Object(this) as FormControl;
        FormDataSource formDatasource = formButtonControl.formRun().dataSource(tableStr(WHSLoadTable));
        WHSLoadTable whsLoadTable = formDatasource.cursor();
        Args    args;
        FormRun formRun;
        args = new Args(formStr(WHSLoadPlanningListPage));
        args.record(whsLoadTable);
        FormRun = classFactory.formRunClass(args);
        formRun.init();
        formRun.run();
        FormButtonControl ASCValidate = formRun.design().controlName(formControlStr(WHSLoadPlanningListPage,ASCValidation)) as FormButtonControl;
        ASCValidate.clicked();
        next clicked();
    }
}

3.I tried above code, while debugging the validate button coc clicked method did not triggered.


 
 
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    lt'll be much easier when you design your code correctly.
     
    You're struggling with calling your logic because you've put it at a wrong please. As you see, having it in clicked() method of a button make it very difficult to reuse, so fix that. Find or create a class suitable for this logic and put the validation logic to a method there. Then call the method from both places.
     
    Also, extending WhsLoadPlanningListPageForm.btnProductReceipt_clicked() is likely a better idea than extending btnProductReceipt.clicked().      
     
    Your idea of constructing the whole WHSLoadPlanningListPage form just to call the validation makes everything more complicated and less efficient.
     
     

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans