Search:

Testing data filters in OnValidate trigger

Data Security ensures that only the records the user is allowed to see are being shown. But for entering values, the user is able to type anything in the fields. The code below will ensure that the value entered is within the filtered values.

Form 42 Sales Order
Sell-to Customer No. - OnValidate
--- Before ----
InPage=0;
SourceExpr="Sell-to Customer No.";
OnAfterValidate=BEGIN
                  CurrForm.UPDATE;
--- After -----
InPage=0;
SourceExpr="Sell-to Customer No.";
OnValidate=VAR
             ESCustomer@1000001 : Record 18;
             ESFLADSSetFilters@1000002 : Codeunit 14123812;
           BEGIN
             ESCustomer.RESET;
             ESFLADSSetFilters.Filter18(ESCustomer,2,FORM::"Sales Order");
             ESCustomer."No." := "Sell-to Customer No.";
             ESCustomer.FIND('=');
           END;

OnAfterValidate=BEGIN
                  CurrForm.UPDATE;
---------------

Page 42 Sales Order
Sell-to Customer No. - OnValidate
--- Before ----
HideValue=ESACC_F2_HideValue;
OnValidate=BEGIN
             SelltoCustomerNoOnAfterValidat;
           END;
--- After -----
HideValue=ESACC_F2_HideValue;
OnValidate=VAR
             ESCustomer@1000001 : Record 18;
             ESFLADSSetFilters@1000002 : Codeunit 14123812;
           BEGIN
             ESCustomer.RESET;
             ESFLADSSetFilters.Filter18(ESCustomer,8,PAGE::"Sales Order");
             ESCustomer."No." := "Sell-to Customer No.";
             ESCustomer.FIND('=');

             SelltoCustomerNoOnAfterValidat;
           END;
---------------

Basically, Codeunit 14123812 "ES FLADS Set Filters" is used to ensure that the record entered is within the filtered values. The RESET is only removing editable filters. Filters applied hidden are not affected by this line of code. If the editable filters are going to be required, this line should be left out of the code.

This code is not implemented by the FLADS install engine and is not planned for future versions. A programmer must implement and remove this manually.



Like   Don't Like

© 2024 Mergetool.com. All rights reserved.



Related resources

Download software from Mergetool.com