Newer Version Available

This content describes an older version of this product. View Latest

Create Transaction Security Policies

Create your own custom policies triggered by specific events. Only an active user assigned the System Administrator profile can use this feature.
Available in: Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions

Requires purchasing Salesforce Shield or Salesforce Event Monitoring add-on subscriptions.


User Permissions Needed
To create, edit, and manage transaction security policies:

Customize Application

To manage transaction security policies:

Author Apex

You can create multiple policies for the same type of event, but we recommend that your policies and their actions don't overlap. If multiple policies with the same action for a given event execute when the event occurs, their order of execution is indeterminate.

  1. From Setup, enter Transaction in the Quick Find box, select Transaction Security Policies, and then click New.
  2. If you are participating in the Real-Time Events pilot, select whether you want to create a policy with the Condition Builder wizard or with an Apex class. If you’re not in the pilot, skip to step 3.
  3. Select the event or entity that your policy monitors.

    AccessResource event policies don't trigger when Dashboard Subscriptions send an email. These policies still trigger when users access resources directly from a dashboard. Lightning Experience supports only the Feed Comment and Feed Item resources, while Salesforce Classic supports all Chatter resources. You can’t create a Data Export event policy for joined reports, historical reports, or custom report types.

    Note

  4. If you’re creating an Apex-based policy in a non-production environment, in Apex Class, select New Empty Apex Class. (Transaction Security creates a stub, or placeholder, Apex policy condition.) Otherwise, use an existing Apex policy condition.
  5. Select what the policy does when triggered and who is notified and how. If you’re creating an Apex-based policy, specify the user that the policy executes as. Any users you select must have Modify All Data and View Setup permissions.
    The actions available vary depending on the event type. For login and resource events, you can also block the action or require a higher level of access control with two-factor authentication. For Chatter events, you can freeze the user or block the post. For Login events, you can require ending an existing session before continuing with the current session. You can set the default action for ending a session to always close the oldest session. For more information, see What Are Transaction Security Actions?

    Two-factor authentication is not available in the Salesforce app or Lightning Experience for the Resource Access event type. The Block action is used instead.

    Note

  6. Choose a descriptive name for your policy. Your policy name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
  7. To enable the policy after you create it, in Status, switch to Enabled. (You can always disable it later from the Transaction Security Policies page.)
  8. Click Finish.

If you’re in a non-production environment and you selected New Empty Apex Class for your new policy, modify the generated Apex class now before activating your policy. Click the Apex class name to get started, and add the condition that triggers the policy. See Apex Policies for Transaction Security for examples.