In this article, I'll explain the process of personalizing Guardrail warnings by adding or removing them.
1.Customizing Guardrail warnings by adding your own.
Create an activity called "CheckForCustomWarnings" within the Rule class where you intend to include additional warnings. Differentiate it from the existing "CheckForWarnings," which is present in all Rule classes and cannot be overridden due to its Final status. For instance, if you aim to append warnings to a Flow action, establish this activity in the Rule-Obj-FlowAction class. Implement the following Java code and set up the When condition accordingly.
Following this implementation, if you leave the description of the Flow Action rule empty, the system will issue a severe warning as shown below.
2.Eliminate default(OOTB) Guardrail warnings.
While it is not advisable to remove the default warnings, as they serve to verify if the developer's code adheres to best practices, there might be exceptional cases where you may consider doing so. For instance, I recently identified an issue in the warning logic related to Obj-Browse. When specifying an optimized property under a Single Page for filtering, the system triggers a "pzObjBrowse-InvalidProp" SEVERE warning without a valid cause. This issue has been recognized as a product defect .While it can be justified temporarily, I prefer to eliminate it since it still contributes to the overall count of warnings.
In such scenarios, you have the option to suppress the warnings. Generate an activity named "CheckForCustomWarnings" within the Rule class from which you wish to eliminate warnings. In the given example, position it in the Rule-Obj-Activity class. Subsequently, implement the following Java code.
//Removing warning from page .pxWarnings ClipboardProperty warningslist = myStepPage.getProperty(".pxWarnings"); for (int i = warningslist.size() ; i > 0; i--) { ClipboardPage row = warningslist.getPageValue(i); String s = row.getProperty(".pxWarningName").toString(); if (s.equals("pzObjBrowse-InvalidProp")) { warningslist.remove(i); } } //Removing warning from page .pxWarningsToDisplay ClipboardProperty warningtodisplay = myStepPage.getProperty(".pxWarningsToDisplay"); for (int i = warningtodisplay.size() ; i > 0; i--) { ClipboardPage row = warningtodisplay.getPageValue(i); String s = row.getProperty(".pxWarningName").toString(); if (s.equals("pzObjBrowse-InvalidProp")) { warningtodisplay.remove(i); } }
Substitute "pzObjBrowse-InvalidProp" with the specific warning name you intend to eliminate. If you wish to suppress multiple warnings, concatenate them using the || (OR) operator.
The Java code in the "(2) Remove out-of-the-box Guardrail warnings" section can be translated into an activity using the following implementation:
Happy Learning :)
Comments
Post a Comment