How do I run additional code together with a Popout system-defined button

I would like to run additional code when pressing the system button “Popout” on the right corner of a standard d365fo form(ex.SalesTable). What i need is to popou the window as the standard functionality did and then I want to show an info message. I would like to do this for multiple forms that’s why I want to do this more generic.

What I did until now:

  • I made an extention of the FormRun class and overide the onFormRun method

[ExtensionOf(classStr(FormRun))]
public final class FormRun_Test_Extension
{
[SubscribesTo(classStr(FormRun), staticDelegateStr(FormRun, onFormRun))]
public static void onFormRun (FormRun _formInstance)
{
GeneralEventHandlers::onFormRun(_formInstance);
}
}

class GeneralEventHandlers
{
static void onFormRun (FormRun _formRun)
{
#SysSystemDefinedButtons
FormCommandButtonControl popoutButton;
popoutButton = _formRun.control(_formRun.controlId(#SystemDefinedPopoutButton)) as
FormCommandButtonControl;
popoutButton.OnClicked += eventhandler(EDD3OEventHandlers::Test);
}
}

public static void Test(FormControl sender, FormControlEventArgs e)
{
info(“Test”)
}

The problem is that the info message is not shown when I press the ‘Popout’ System button and the form appeared on the popout window. What am i missing? Am I on the correct dirrection? FYI: I already already read system-defined-buttons article.

I’m not sure what you mean by “the form appeared on the popout window”. Can you explain that, please?

By “the form appeared on the popout window” I mean:
When we press the Popout system button on the right corner of a form a new window appeared.

Okay, so you’re saying that it still works the same as before; your code has no effect, correct?

What did you find when you debugged your code? Is Test() method executed?

Unfortunatelly, during dubugging Test() method did not executed.

I don’t know, but I would try doing it earlier than in OnFormRun.

I try to override/Extend the SystemDefinedPopoutButton for more that one standard d365fo forms. How I could achive to execute extra functionality when I press this system button? If you have any proposal for ‘earlier than in OnFormRun’ doing, please help me.

Does anyone has any proposal on how I could override/extend the functionality of the SystemDefinedPopoutButton on the right corner of a form?
image

What I findout is that when I try to execute the form command button(Popout) and the command executed, the Test method will not be executed. If I run a similar command button without the command, the Test method will be executed.

class GeneralEventHandlers
{
static void onFormRun (FormRun _formRun)
{
#SysSystemDefinedButtons
#macrolib.Task
FormCommandButtonControl popoutButton;

popoutButton = buttonGroup.addControl(FormControlType::CommandButton, ‘SystemDefinedPopoutButton1’);
//popoutButton.command(#taskPopout);
popoutButton.imageLocation(SysImageLocation::Symbol);
popoutButton.normalImage(“PopoutExpand”);
popoutButton.buttonDisplay(ButtonDisplay::ImageOnly);
popoutButton.OnClicked += eventhandler(TestEventHandlers::Test);
}}
Any idea how to overcome this problem?