Override of a Method: General Information
In a graph extension, you can override the virtual methods defined within the base graph.
Applicable Scenarios
You need to adjust standard system behavior (such as document release, validation, or data persistence) to meet specific business requirements.
Requirements to the Graph Method and Its Override
We recommend that you follow these requirements when you are defining the override of a method of a graph:
-
The method that you are going to override must have one of the following access modifiers:
publicprotectedprotected internal
- The override of the method must always be a
public, non-static, and non-virtualmethod. - The override of the method must have the PXOverride
attribute.
Because the PXOverride attribute on the declaration of the method is included in the graph extension, it forces the system to override the original method in the graph instance. Otherwise, both the base method and the overridden method will be invoked.
- If the base method contains a list of parameters, you must include the same list of parameters in the declaration of the override method.
- The override of the method must include the base delegate parameter as the last
parameter in the list of parameters. The name of the parameter must begin with
base_, followed by the name of the method. This parameter represents the delegate for one of the following:- The override method with an additional parameter from the graph extension of the previous level, if such a method exists
- The base virtual method, if no override methods with additional parameters are declared within lower-level extensions
- You should add an XML comment with an
Overridesprefix and the<seealso>tag to the declaration of the override of the method. The value of thecrefproperty of<seealso>should reference the base method that you are overriding. This comment should not be included within the<summary>tag.
See the following example of an override of the WorksheetPicking.IsWorksheetMode(string) method, which follows all these guidelines.
/// Overrides <seealso cref="WorksheetPicking.IsWorksheetMode(string)"/> [PXOverride] public bool IsWorksheetMode(string modeCode, Func<string, bool> base_IsWorksheetMode) { // Add your code base_IsWorksheetMode(modeCode); }
How the Override Method Works
The override method with an additional parameter replaces the base graph virtual method. When the virtual method is invoked, the system invokes the override method with an additional parameter of the highest-level graph extension. The system passes a link to the override method with an additional parameter from the extension of the previous level, if such a method exists, or to the base virtual method.
