Create a Restore Trigger

Last published at: March 10th, 2026

Plauti Restore uses an apex trigger to keep track of changes made to a record. If such a trigger does not yet exist for a certain Object, or is inactive, the Object Setup page opens with a ‘Complete Configuration’ section.

  • If you already have a Restore Trigger for this Object, make sure that it is Active
  • If not, create a Trigger and a Test Class, and prepare your Production org for deployment.

As per Salesforce policy, you first need to create the Apex Trigger and Test Class in your sandbox and then deploy from sandbox to production.

Apex Triggers will work in Sandbox without a Test Class, but you will need a test class for deploying a trigger in Production.

 

Creating a Trigger

First create the trigger:

  1. Go to Plauti Restore > Restore Setup > Object Configuration.
  2. In the ‘Complete Configuration’ section, click Copy to Clipboard to copy the trigger code for this Object.
  3. Go to Salesforce Setup > Object Manager > select the Object.
  4. At left, go to Triggers and click New .
  5. In the code section, remove the default code and paste the copied trigger code.
  6. Make sure Is Active is ticked.
  7. Save the trigger.

Creating a Test Class

Then create an ‘insert’ test class:

  1. Go to Salesforce Setup > Custom Code > Apex Classes.
  2. Click New.
  3. Enter the Apex Test Class code below. 
    • Replace *OBJECT_NAME* and *OBJECT_API_NAME* with the name and API name of your Object. 
    • Insert any required related Objects as well.
    • Add all fields that are required to insert a record for the Object.
// TEST CLASS BELOW
@isTest
private class TestPR*OBJECT_NAME* {
   @isTest
   static void Test_Insert*OBJECT_NAME*() {
       // Create required related objects if applicable. For example:
       // Account acc = new Account(Name = 'Test Account');
       // insert acc;
       
       *OBJECT_API_NAME* p = new *OBJECT_API_NAME*();
       // Add all required fields for the record. For example;
       // p.Name = 'TestAsset';
       // p.CurrencyIsoCode = 'USD';
       // p.AccountId = acc.Id;
       insert p;
       system.assertEquals(true, p.Id != null);
  }
}
  1. Save the class and click Run Test. Solve any errors that might occur. 
  2. After you created the trigger and test class in Sandbox, check if your Production org is ready for deploying the trigger. 
     

Preparing your Production org

To be able to deploy the trigger to production, the Object should be added and deployed in Plauti Restore in your Production environment. Check the following:

  1. In your Production Org, go to Plauti Restore > Restore Setup > Object Configuration.
  2. Check that the Object is present in the list of objects. 
    • If the Object is not in the list yet, continue below.
    • If the Object is in the list, but you see an orange banner stating that your changes have not been submitted yet, click ‘Deploy Settings’ and wait for the settings to be deployed.


To prepare an Object for deploying a trigger in Production:

  1. In your Production Org, go to Plauti Restore > Restore Setup > Object Configuration.
  2. At right, click Add Object .
  3. Find the Object and click Add .
  4. In the top banner that appears, click Deploy Settings .

Once the Object is deployed, Plauti Restore in your Production Org is ready to have the trigger deployed from Sandbox. 

The next steps

  1. First, follow the deployment steps in Deploy change sets from sandbox to production to deploy the trigger to Production.
  2. Then configure the Object in Production as described in Object Configuration
    The warning to complete your configuration first should not appear anymore; if it does, this means that the trigger you just deployed is inactive. Activate it before continuing configuration.

Example

For example, a trigger and test class for Assets could look like this:

Trigger

Copied from the “Complete Configuration” box in the Asset Object Configuration in Restore Setup.

trigger prAssetChangeTrigger on Asset(after insert, after update, after delete, after undelete, before delete) {  plauti.prTriggerWrapper triggerWrapper = new plauti.prTriggerWrapper(Trigger.operationType, Asset.getSObjectType()); triggerWrapper.processTrigger(Trigger.new, Trigger.oldMap);}

Test class

Assets require an Account or Contact as related Object, and Asset Name, Asset Currency and the related Account or Contact as required Fields.

Note that *OBJECT_NAME* and *OBJECT_API_NAME* have been replaced with the Asset name and API name. 

// TEST CLASS BELOW
@isTest
private class TestPRAsset {
   @isTest
   static void Test_InsertAsset() {
       Account acc = new Account(Name = 'Test Account');
       insert acc;
 
       Asset p = new Asset();
       p.Name = 'TestAsset';
       p.CurrencyIsoCode = 'USD';
       p.AccountId = acc.Id;
       insert p;
       system.assertEquals(true, p.Id != null);
   }
}