Reading list Switch to dark mode

    How to work with Transaction Security in Salesforce

    Updated 17 August 2017

    In this blog, we will learn about how we can work with Transaction Security. Before we start working on it, we should have knowledge about what it states in salesforce.

    Transaction Security

    Transaction Security in Salesforce refers to provide security while an event or a transaction, for ex- login, data export or accessing resources. It is a feature that monitors Salesforce events in real time and takes action with respect to rules i.e. policies that we create. Basically, you can divide it into three parts, i.e. Events, Notification, and Action. Let’s discuss it thoroughly.

    Events: The events which are available:

    • Data Export for selected objects (Accounts, Case, Contact, Lead, and Opportunity)
    • Entity for Authentication providers and login Ip
    • Login, for limiting the session and client browser.
    • Access resources for connected app and reports and dashboards

    Notification: It states that the event has occurred as well as the criteria are satisfied for the policy to be triggered. We can notify the end user through following ways:

    • Email
    • In App Notification in Salesforce 1

    Action: The actions which we can take when the criteria is satisfied.

    Searching for an experienced
    Salesforce Company ?
    Find out More
    • Block the operation
    • Two-factor authentication
    • End the current Session
    • Send notification


    First of all we have to enable transaction security.

    Step 1: Go to Setup > Security Controls > Transaction Security.

    Step 2: Enable.


    Let’s take an example. In this example, we will restrict login from Safari Browser.

    Step 1: Go to Setup > Security Controls > Transaction Security. Click New.

    Step 2: Fill the related information as mentioned in the image below and Save.


    As you chose Generate Apex option, you can now observe an apex class is generated as following:

    global class RestrictLoginSafariPolicyCondition implements TxnSecurity.PolicyCondition {
      public boolean evaluate(TxnSecurity.Event e) {
        LoginHistory eObj = [SELECT ApiType FROM LoginHistory WHERE Id ='LoginHistoryId')];
        if(eObj.ApiType == 'Safari') {
          return true;
        return false; 

    As well as, you will be unable to login by Safari browser.


    That’s all for how we can work with Transaction Security, still, if you have any issue feel free to add a ticket and let us know your views to make it better


    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content