GRAX Documentation

The GRAX Documentation Hub

Welcome to the GRAX Documentation hub. You'll find comprehensive guides and walkthroughs to help you start working with GRAX as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Object Time Machine

Let's walk through how to set up the GRAX Object Time Machine in order to track changes to every field on a particular set of defined objects.

Configure Page Layout

📘

Salesforce Lightning vs Classic

The configuration section is divided into two sections: Lightning and Classic. Please follow the instructions that coincide with your environment.

Lightning

  1. Go to your Salesforce environment where you have installed the GRAX Application
  2. Go the page where you would like to update the page layout and select the gear in the top right corner and then “Edit Page”
  3. Click on the list of tabs and click “Add tab” and give it an appropriate name
    a. Our recommendation is to name the tab “Object Time Machine”
  4. Click on the tab and from the left drag on Lightning Component “Visualforce”
  5. Set the options as below:
    a. Visualforce Page Name: GraxTimeMachine
    b. Height: We recommend 700, but use your discretion
  1. Click “Save” and make sure that the page has been “Activated”
  2. You should now see a tab for “Object Time Machine”, similar to below:

Classic

  1. Go to your Salesforce environment where you have installed the GRAX Application (Classic Environment).
  2. Once logged in, click the Setup button at the top right.
  3. In the Quick Find / Search search box (top left) type Visualforce and select Visualforce Pages from the menu.
  4. Select New to create a new VisualForce page.
  5. In the label and name fields enter GRAX Restore and paste the following code into the Visualforce Markup and click Save:

The following example will display related records on the Account object:

<apex:page standardController="Account" showHeader="false" sidebar="false">
  <apex:variable var="recordId" value="{!Account.Id}" />
  <apex:variable var="recordName" value="{!Account.Name}" />
  <apex:variable var="groupVersionsByRecord" value="false" />
  <apex:variable var="height" value="700px" />
  <apex:variable var="width" value="100%" />
  <apex:variable var="scrolling" value="true" />
  <apex:iframe src="/apex/grax__GRAXTimeMachine?Id={!recordId}&recordName={!recordName}&groupVersionsByRecord={!groupVersionsByRecord}&isEmbedded=1" height="{!height}" width="{!width}" scrolling="{!scrolling}"/>
</apex:page>

Parameter Breakdown:

Parameter

Value

Description

recordId*

{!sObject.Name}

This is the Id of the sObject that the Time Machine VF page resides on.

recordName*

{!sObject.Id}

This is the name of the sObject that the Time Machine VF page resides on.

groupVersionsByRecord*

false

This toggle removes grouping of records, where only the latest would be shown.

isEmbedded

1

This field embeds the Restore iFrame into the VF page.

height

"700px"

This parameter defines the height of the Restore iFrame.

scrolling

"true"

This parameter enables scrolling in the Restore iFrame.

📘

Note

The suggested default values are noted in the table above. Fields marked with "*" can be changed on a per object basis. Changing other values may have unintended results.

  1. Navigate to the sObject record that you want to add the Visualforce page to (ie. Account).

  2. On the record page, click Edit Layout at the top right of the page.

  3. Add a new section and label it Object Time Machine. Set the layout to 1-Column, deselect Edit Page and click OK.

  4. In the dropdown at the top of the page, scroll down to Visualforce Pages on the left hand column. Once selected, find the GRAX Restore page and drag it into the corresponding section.

  5. In the new section where you dragged the Visualforce page into, click on the wrench on the far right (Properties). Set the height to recommended value of 700, select Show scrollbars option, and click OK.

  6. Select Save in the dropdown at the top of the page to save the page layout.

Create SFDC Trigger and Setting up Audit Trail

  1. It is important to note that you will need a trigger on every object where you are using the Object Time Machine. Without a trigger on this object, this feature will not work.
  2. Go to your Salesforce environment where you have installed the GRAX Application
  3. Click on the tab Configuration
  4. Scroll down to the Apex Trigger(s) section
  5. Select the object that you want to use the Object Time Machine on, for example “Account”
  6. Copy the trigger and test class and create in your environment per your normal trigger creation best practices.

📘

Asynchronous Option

Notice in the sample code snippet that there is an option to change a parameter to false in order to execute the process asynchronously. Your Salesforce SI/developers will want to review to follow best practices. More on best practices below.

trigger GRAXTriggerExample on Account (after update, after insert, after delete, after undelete) {
    // -------------------------------------------------
    // https://GRAX.io/
    // Support Contact - Support At HardingPoint.com
    // -------------------------------------------------
    try {
        // Please change the 3rd parameter to "false" if you want to execute this process asynchronously (Queueable job)
        grax.GRAXApi.jsonContentCallout(Trigger.new, Trigger.old, true);
    } catch(exception ex) {
        // Handle all exceptions from environment.
        System.debug('[GRAX Trigger Account] ' + ex.getMessage());
    }
}
  1. One way to to create the trigger --> go to the Developer Console, then click file --> new --> Apex Trigger
  2. Name your trigger and set the sObject to the correct object, in our example “Account” and then click submit
  1. Paste in the code from the example above and then click File and then Save and your trigger is created.
  2. Repeat the above steps on any, and all, objects where you will be using the Object Time Machine.

📘

Apex Trigger Best Practices

The example trigger mockup and example test class are just that: an example for you to build upon. It is critical to work with your Salesforce SI and Salesforce developers to integrate the time machine code efficiently into your trigger factory. Given that it can fire upon every DML on an object, you also may want to configure the trigger to fire asynchronously. There are various Salesforce trigger and asynchronous limits depending on your org-type, so please consult with your SI to understand best practice for incorporating a new trigger for a specific object(s).

Additionally, you will need to build out the test class to write appropriate tests for the specific object you want time machine enabled for.

Using Object Time Machine

  1. Once all of the above steps are completed, go to the record where you want to view the Object Time Machine.
  2. Make an edit/update to fields on this object and then click “save”
  1. Click on the tab “Object Time Machine” and you should see the update that you just made, and any previous updates towards the bottom of the Object Time Machine section.

You can use the filters to refine the results.

  1. Click on the record which you want to review in more detail and click “Load this Version”. When you do that, you will see something similar to below:
  1. In the above image, we are able to see the following:
    a. Location: This is the Amazon S3 link for this specific record in your Amazon S3 environment
    b. Display all field values button: When this button is clicked, the user will see every single field, and its value, on this record. This is very important for audit purposes.
    c. Field: This is the field which was updated
    d. New Value: This is the new value of the record after the update was made
    e. Old Value: This was the value of this field prior to the change that was made
    f. Current Value: This is the current value for this specific field
  2. Depending on the user’s permissions, which are set via the permission set, the user could see the following buttons:
    a. Restore to Old Version: This will update this record to the field values in the column “Old Value”
    b. Update to this Version: This will update this record to the field values in the column “New Value”.
  3. If the user clicks either of the above buttons “Restore to Old Version” or “Update to this Version”, they will get the below warning pop-up, prior to saving:
  1. Once, or if, a user updates to a previous version, this will also create a row in this table since the user is updating this record.

Updated 3 months ago

Object Time Machine


Let's walk through how to set up the GRAX Object Time Machine in order to track changes to every field on a particular set of defined objects.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.