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.
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:
- Go to Plauti Restore > Restore Setup > Object Configuration.
- In the ‘Complete Configuration’ section, click Copy to Clipboard
to copy the trigger code for this Object. - Go to Salesforce Setup > Object Manager > select the Object.
- At left, go to Triggers and click New
. - In the code section, remove the default code and paste the copied trigger code.
- Make sure Is Active is ticked.
- Save the trigger.
Creating a Test Class
Then create an ‘insert’ test class:
- Go to Salesforce Setup > Custom Code > Apex Classes.
- Click New.
- 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 TestDC*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);
}
}- Save the class and click Run Test. Solve any errors that might occur.
- After you created the trigger and test class in Sandbox, you can then deploy from sandbox to production.
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.prTriggerProcess triggerTool = new plauti.prTriggerProcess(Trigger.operationType, Asset.getSObjectType()); triggerTool.execute(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);
}
}