How To: Clone a Parent Object and Move Child Records to the New Parent Object
May 25, 2017
How To: Clone a Hierarchy of Records Asynchronously with Super Clone Pro
February 19, 2018

How To: Filter Records in Related Lists With Super Clone Pro

Some Super Clone Pro cloning and editing use cases require filtering out records from child relationships. Filtering child relationship records can be accomplished in two ways. First, the configuration can use a checkbox field to filter records from an object. Second, a ‘selectwhere’ parameter can be used to pass selection criteria to a page, process builder or API.

Checkbox Filtering
URL Parameter Filtering

 

Checkbox Filtering

In the field section of the configuration, there is a Filter By option that shows a list of field names from the object that are the checkbox field type. These fields can be a normal checkbox or checkbox formula field. When the filter field is specified, records where the field’s value is equal to true/checked will be included from the relationship. Records where the field’s value is equal to false/unchecked will be excluded. The checkbox formula field lets you leverage the power of Salesforce’s formula engine, so you can include logic that contains references to related objects, conditions, date calculations, etc.

  • None – The none option indicates no filter field has been selected, and the all available records will be included.

 

URL Parameter Filtering

The recommended filtering approach is to use the checkbox filtering. However, some objects do not allow the creation of custom fields, like Attachment. A URL parameter named ‘selectwhere‘ is available. The value of this parameter can include filtering conditions for multiple conditions with the ability to do basic AND/OR logic. This parameter can be used in custom buttons, components, and API interfaces.

There is a specific format that the conditions must be in. A filtering condition will be ignored if the format is not correct. The basic formatting is a list of conditions delimited by ‘;;’. Within that list, elements are delimited by ‘:’.  Conditions for the same object are combined as an ‘AND’ operation.  Conditions that require an ‘OR’ operation will start with ‘||’ before the object name. The format is objectName:fieldName:comparisonSymbol:comparisonValue;;    Syntax can get confusing, but bear with me until we got to a few examples.

Optionally, the CloneObject__c record Id can be used instead of the ‘objectName’. Use the record Id when the same object is in multiple parts of the relationship hierarchy, and filtering requirements are different. The CloneObject__c record Id isn’t displayed on the configuration. It can be found by looking at the CloneObject__c record using the standard Salesforce pagelayout. From the configuration list page, click on the ‘Clone Object’ link at the bottom. Then find the record by looking at the Clone Index and Path Id field for the configuration.

Comparison Options

Comparison symbols include:

  • =‘ equals to
  • >=‘ greater than or equal
  • <=‘ less than or equal
  • >‘ greater than
  • <‘ less than
  • !=‘ not equal
  • b‘ means a field value begins with a specific value
  • e‘ means a field value ends with a specific value
  • c‘ means a field value contains a specific value
  • nb‘ means a field value does not begin with a specific value
  • ne‘ means a field value does not end with a specific value
  • nc‘ means a field value does not contain a specific value

Basic Filter

This condition requires ‘field1’ of ‘object1’ to equal ‘valueA’.

Basic AND Logic

This condition requires ‘field1’ of ‘object1’ to equal ‘valueA’ AND ‘field2’ of ‘object1’ to equal ‘valueB’. The conditions are delimited with the ‘;;’, and the AND condition is assumed when the OR logic is not found.

Basic OR Logic

This condition requires ‘field1’ of ‘object1’ to equal ‘valueA’ OR ‘field2’ of ‘object1’ to equal ‘valueB’. Notice after the ‘||’ after the ‘;;’ delimiter and before the object name.

Complex OR Logic: Require the same value for Field1, but allow Field2 to equal valueA or valueC 

In this example, the first condition requires ‘field1’ to equal ‘valueA’ and ‘field2’ to equal ‘valueB’. Then there is an ‘OR’ condition. The second part requires ‘field1’ to equal ‘valueA’ again, and ‘field3’ to equal ‘valueC’. All conditions are for ‘object1’.  The ‘field1’=’valueA’ is duplicated in each part of the ‘OR’ logic.

The condition would look like this if the logic was written out as a formula field expression.

Example: Filter Attachments of type ‘.jpg’, ‘.png’, and ‘.tif’ with a file name containing ‘FINAL’

This filter will ORs to filter the three file types, and the logic to check if the file name contains ‘FINAL’ will be repeated in each OR condition.

Example Custom Button URL

The custom button containing the page and other parameters would look like this.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.