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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to override or cha...
Finance forum

How to override or change clicked method in form D365FO?

(0) ShareShare
ReportReport
Posted on by 3,805

Hi,

i have question about clicked method like this.

for example : in form WHSLoadPlanningWorkbench for button ValidateLoad, i can see method clicked like this:

void clicked()
{
  loadPlanningWorkbenchForm.validateLoad_clicked(whsLoadTable_ds);

  super();
}

i want to add condition for this button like this :

void clicked()
{

  if(whsLoadTable.DSI_Flag == NoYes::Yes)

  {

    error("Error");

  }

  else

  { 

    loadPlanningWorkbenchForm.validateLoad_clicked(whsLoadTable_ds);

  }

 

  super();
}

 

i can use this condition in AX2012.

But, how to create this methods in D365FO.

i try to create extension and copy event handler like this :

[FormControlEventHandler(formControlStr(WHSLoadPlanningWorkbench, ValidateLoad), FormControlEventType::Clicked)]
public static void ValidateLoad_OnClicked(FormControl sender, FormControlEventArgs e)
{
   Args                     args = new Args();
   FormButtonControl callerButton = sender as FormButtonControl;
   FormRun             form = callerButton.formRun();
   FormDataSource whsLoadTable_ds = form.dataSource(formDataSourceStr(WHSLoadPlanningWorkbench, WHSLoadTable)) as FormDataSource;
   WHSLoadTable whsLoadTable = whsLoadTable_ds.cursor();

       if(whsLoadTable.DSI_Flag == NoYes::Yes)
       {
            error("Error");
       }
}

But, i get 2 message :

Untitled.jpg

i want, if flag 'Yes', just show info 'Error'.

please help me.

Thanks.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    You can't skip the super method of the clicked method by using events handlers.

    Currently the best solution is to copy the standard button to your form extension, hide the original button, and override the clicked method of your newly created button.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans