1. Add your Object to the Record Validation Setup
Navigate to the Record Validation Setup page. At the "Object Setup", click "Add Object" and find the Object you wish to configure. Record Validation can work with any Object in Salesforce.
2. Map your field sets for Address, Email and Phone
Navigate to the Address, Email and Phone tabs in the Record Validation Setup and map the fields you want to use with Record Validation.
3. Override your 'New' and 'Edit' button
Override the 'New' button.
- Navigate to the Salesforce Setup.
- Navigate to Platform Tools - Objects and Fields - Object Manager.
- Find your (custom) Object in the list view and access it.
- Navigate to Buttons, Links and Actions.
- Find the 'New' button and click 'Edit'.
- At 'Lightning Experience Override', select 'Lightning Component'.
- In the select list, pick 'recordval:recordForm'.
- Click Save.
Override the 'Edit' button. - Find the 'Edit' button and click 'Edit'.
- At 'Lightning Experience Override', select 'Lightning Component'.
- In the select list, pick 'recordval:recordForm'.
- Click Save.
4. Create all required custom fields
Create the custom field "RV Record Status"
- Navigate to Salesforce Setup. Navigate to the Object Manager.
- Find and Open your custom object. Click on "Field & Relationships"
- Click the "New" button.
- Step 1. Under Data Type choose "Picklist" and click Next.
- Step 2. Fill only the following information and then click Next:
Field Label: RV Record Status
Values: Click on the drop-down menu and select "RV Record Status" option.
Field Name: rv2Status
- Step 3. Depending on your Salesforce edition (Professional and up), you will now get a screen to establish field-level security. Click 'Next'.
- Step 4. Depending on your Salesforce edition (Professional and up), you will now get a screen where you are able to add the field to the page layout. Since this is a background process, this should not be applied to any page layout. Uncheck any page layout and click Next.
- Now, after creating the "RV Record Status" field, you need to map it in the RV Setup. Navigate to RV Setup and click on the Custom Object
- Select the field from the drop-down menu under "Field Configuration".
5. Create the custom field "RV Validation Result"
Create the custom field "RV Validation Result"
- Navigate to Salesforce Setup. Navigate to the Object Manager.
- Find and Open your custom object. Click on "Field & Relationships"
- Click the "New" button.
- Step 1. Under Data Type choose "Text Area(Long)" and click Next.
- Step 2. Fill the following information and then click Next.
Field Label: RV Validation Result
Field Name: rv2Validation
- Depending on your Salesforce edition (Professional and up), you will now get a screen to establish field-level security. Click 'Next'.
- Step 4. Depending on your Salesforce edition (Professional and up), you will now get a screen where you are able to add the field to the page layout. Since this is a background process, this should not be applied to any page layout. Uncheck any page layout and click Next.
- Now, after creating the "RV Validation Result" field, you need to map it in the RV Setup. Navigate to RV Setup and click on the Custom Object
- Select the field from the drop-down menu under "Field Configuration".
6. Create the Apex Trigger (mandatory)
- Go to the Salesforce Setup > Object Manager.
- In the Object Manager, find the custom object you want to use and click on it.
- Under Details, copy the API Name of the Object.
- At the left, go to the Triggers tab.
- At top right, click New.
- Replace all code in the box with the Apex Trigger code below. Make sure you replace *OBJECT_NAME* and *OBJECT_API_NAME* with the name and API name of your Custom Object.
Click here to watch a short video of this step.
trigger rv2**ObjectName** on **OBJECT_API** (after delete, after insert, after undelete, after update, before delete, before insert, before update) {
if (!recordval.rv2Trigger.triggerSource.equalsIgnoreCase('SELF') || recordval.rv2TriggerMapper.isTriggerDisabled()) { return; } recordval.rv2Trigger triggerProcess = recordval.rv2TriggerMapper.get('**OBJECT_API**', 'rv2Status__c', 'rv2Validation__c'); triggerProcess.execute(trigger.new, trigger.oldMap,trigger.isBefore, trigger.isAfter, trigger.isInsert, trigger.isUpdate, trigger.isDelete, trigger.isUndelete); } Click Save.
The trigger has been created.