Compartir a través de


Function events

Functions provide the following events:

  • InvokeBeforeOriginal
  • InvokeAfterOriginal

InvokeBeforeOriginal

This event occurs when the function is invoked, but before the original function is run. The event arguments allow access the parameters and return value of the function. Refer to Parameters for functions to learn more about working with parameters and return value in function events.

InvokeAfterOriginal

This event occurs when the function is invoked, but after the original function is run.The event arguments allow access the parameters and return value of the function. Refer to Parameters for functions to learn more about working with parameters and return value in function events.

The following C# example registers the InvokeAfterOriginal event for the GetAutoComplete function of the UserDefaultsForm in Microsoft Dynamics GP.

UserDefaultsForm.Functions.GetAutoComplete.InvokeAfterOriginal +=
new SyUserDefaultsForm.GetAutoCompleteFunction.InvokeEventHandler(
GetAutoComplete_InvokeAfterOriginal);

The following C# example is the event handler for the event registered in the previous example. The event handler uses the event arguments to examine the first parameter passed into the function. If the parameter value is "DYNSA", the return value of the function is set to false. This will turn off the auto-complete functionality for the DYNSA user.

void GetAutoComplete_InvokeAfterOriginal(object sender, SyUserDefaultsForm.GetAutoCompleteFunction.InvokeEventArgs e)
{
    // Set the return value to always turn off auto-complete for DYNSA user
    if (e.inParam1 == "DYNSA")
    {
        e.result = false;
    }
}