function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Not able to insert record in TxnSecurity.PolicyCondition


  I am using below code to insert data into a custom object using TxnSecurity.PolicyCondition but its not working please suggest me what is the issue in code. 
public class AccountExportLog implements TxnSecurity.PolicyCondition {

public boolean evaluate(TxnSecurity.Event e) {  

        Integer numberOfRecords = Integer.valueOf('NumberOfRecords'));
        String entityName = String.valueOf('EntityName'));
          system.debug('Number of Records ' + numberOfRecords);
           system.debug('EntityName ' + entityName);
             system.debug('entity ' + e);
              system.debug('resource type ' + e.resourceType);
             if(e.resourceType == 'Account'){ 
               //SELECT ID,Name FROM Report WHERE NAME = 'TEST_ACCOUNT_EXP'
                  if(entityName == 'Account'){
            //list<Report_Download_Log__c> rec = new list<Report_Download_Log__c>();
              Report_Download_Log__c rec = new Report_Download_Log__c(API_Type__c = entityName,Download_by__c='00534000009Gu7u',Object_Name__c=entityName,Total_Records__c=numberOfRecords);
              //insert rec;
               //return true;
              //Report_Download_Log__c rec = new Report_Download_Log__c( API_Type__c = entityName,Download_by__c='00534000009Gu7u',Object_Name__c=entityName,Total_Records__c=numberOfRecords);
               //insert rec;
            return false;


kamal somu akamal somu a
The documentation ( from salesforce says that the DML statements is not desirable to use inside the security policies since it might causes error. 

User-added image