• VivekGupta
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi,
I have 4 diff Data Export policies for Lead, Account, Opportunity and Contact object with diff apex classes. 
I would like to know if there is a way to create one single apex class that I can use in one single policy instead of 4 duplicates .
Also, is it possible to use custom settings in policies to store the threshold value of number of records? everytime, i try to access the custom settings in policy apex class, the test class fails.

Thanks,
​Manisha
Has anyone tried setting up a transaction security policy for a specific report? I've tried this sample code in the documentation (https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode.meta/apexcode/apex_interface_TxnSecurity_PolicyCondition.htm) but I could not get it working in my developer org. When I checked the log, the event object content seems to be generic and the entityid which supposed to contain the report id is null.
My policy is set up as: 
Event Type: AccessResource
Resource: Reports and Dashboards
Action: Block /2 -factor auth
 
global class ConfidentialDataCondition implements TxnSecurity.PolicyCondition {
  public boolean evaluate(TxnSecurity.Event event) {
    if(event.resourceType == 'Reports'){  // If the event is about reports...
      List<Report> reports = [SELECT Name FROM Report WHERE Id = :event.entityId];
      if(reports.size() > 0){             // and if there’s a report...
        String name = (String) reports.get(0).get('Name');
        if(!String.isBlank(name) && name.containsIgnoreCase('Quarterly Report FY 2016')){
          return true;  // and if the name meets our criteria, trigger the policy.
        }
      }
    }
    return false;  // Otherwise the policy is not triggered.
  }
}