Salesforce

How to delete audit policies in ABL

« Go Back

Information

 
TitleHow to delete audit policies in ABL
URL Name000051419
Article Number000165802
EnvironmentProduct: OpenEdge
Version: 10.1x, 10.2x, 11.x
OS: All supported platforms
Question/Problem Description
How to delete Audit Policies in ABL

How to delete all records related to an Audit Policy in ABL code
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
In addition to using the Audit Policy Maintenance tool, audit policies can be deleted from the database audit tables using ABL code. This can be useful to replicate changes to multiple databases where the policies need to be kept identical.

The following ABL sample code:
  • Accepts an Audit Policy name as a parameter, and deletes the named policy and its related table, field and event policies.
  • It does not delete any audit records from the _aud-audit-data table that were created due to that policy when the policy was active, thus preserving the integrity of the audit trail.
  • The same new audit records that would be created in _aud-audit-data if the policy was deleted in the Audit Policy Maintenance tool are created when the policy is deleted using ABL code as well.
/* FUNCTION deleteAuditPolicy

    Deletes named audit policy record and all table, field and event policy
    records associated with that policy.
    
    INPUT PARAMETER:    picAuditPolicyName  --    Name of policy to be deleted
    
    RETURNS:    TRUE if all related records successfully deleted
                FALSE if error, transaction rolled back
                
    ERROR:  Sets ERROR-STATUS:ERROR if transaction rolled back
*/                       

FUNCTION deleteAuditPolicy RETURNS LOGICAL
    (picAuditPolicyName AS CHARACTER).

FOR FIRST _aud-audit-policy
    WHERE _audit-policy-name = picAuditPolicyName
    ON ERROR UNDO, RETURN ERROR FALSE:

    FOR EACH _aud-event-policy
        WHERE _aud-event-policy._audit-policy-guid
            = _aud-audit-policy._audit-policy-guid
        ON ERROR UNDO, RETURN ERROR FALSE:
        DELETE _aud-event-policy NO-ERROR.
    END.    /* _aud-event-policy */

    FOR EACH _aud-field-policy
        WHERE _aud-field-policy._audit-policy-guid
            = _aud-audit-policy._audit-policy-guid
        ON ERROR UNDO, RETURN ERROR FALSE:
        DELETE _aud-field-policy NO-ERROR.
    END.    /* _aud-field-policy */

    FOR EACH _aud-file-policy
        WHERE _aud-file-policy._audit-policy-guid
            = _aud-audit-policy._audit-policy-guid
        ON ERROR UNDO, RETURN ERROR FALSE:
        DELETE _aud-file-policy NO-ERROR.
    END.    /* _aud-file-policy */

    DELETE _aud-audit-policy NO-ERROR.

END.    /* EACH _aud-audit-policy */

RETURN TRUE.

END FUNCTION. /* deleteAuditPolicy */



 
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:32 AM

Powered by