Configure a Prefill Generator in Salesforce

   PlatformApplicable to all products in Temenos Journey Manager.  |   All Personas |  All versions This feature is related to all versions.

You can configure a prefill generator against a particular Manager form in Salesforce by following this process:

  1. Identify the data in Salesforce that you wish to use for prefill. This configuration is done in Salesforce by defining a Prefill Generator in the Prefill Generation tab of the Manager app as described below.
  2. Configure where that data will be injected into a form's XML data structure at render time. This configuration is done in the Form Data Config in Manager and is described here.

Create the Prefill Generator Record

  1. In the App Menu, select Transact or simply view All Tabs, then select the Prefill Generation Tab and click New.
  2. Enter the form code of the form - this value must exactly match the form code in Manager.
  3. Retain the default Prefill Generator Class, TransactPrefillGenerator, which allows you to provide JSON configuration to control which fields are included in the prefill generation.
  4. Specify the Generator Configuration as a JSON string according to the specification defined below.
  5. You may also specify a Sample SObject Id that allows you to generate a Sample Prefill XML value and test your configuration.
    Note

    The SObject Id for a Salesforce object can be obtained from the URL while viewing that object.

  6. Click Save to update the changes.
  7. Click Generate Sample to test the configuration (if you have provided a Sample SObject Id). The generated prefill XML data will be added to the Sample Prefill XML field, if your configuration is correct.
    Note

    Currently the Generate Sample button is not visible in Salesforce Lightening, so you must switch to Classic mode to have it displayed.

  8. You may copy the sample prefill XML and use this in Manager to define your Input XML prefill mappings for the form.

Managing Form Versions

Where you need to perform different prefill generation between multiple versions of a form you may append an array of versions to the form code attribute to target specific versions. For example, you may wish to have 2 separate prefill generators, one for the first version of the form and another for subsequent versions. This will allow you to configure the prefill generation for new form versions prior to activation of those versions.

To utilize this feature you must specify the specific version numbers as an array directly after the form code. Some samples assuming a form code of 'my-form':

  • my-form - Default configuration to be used where no specific configuration is found for the requested version. Shorthand for use of wildcard my-form[*].
  • my-form[1.0] - Configuration for version 1.0 of the form. Any versions other than 1.0 will fall back to the default configuration (where no version is specified).
  • my-form[1.0,2.0,3.0] - Configuration for versions 1.0, 2.0 and 3.0 of the form.

JSON Configuration Format

This section describes the syntax and supported directives of the JSON configuration consumed by the TransactPrefillGenerator class. This article assumes knowledge of JSON formatting. The JSON configuration should conform to the following structure:

{
    "parameters":{
        "<param-name>": "<param-value>"
    },
    "sobjects":{
        "<object-type-name>": {
            "includeFields": ["<field-name>", ... ],
            "includeRelated": ["<relationship-name>", ... ],
            "includeCustom": {"<custom-label>": "<custom-value>", ... }
        },
        ...
    }
}

The following example configuration illustrates all supported directives:

{
    "parameters":{
        "rootElementName": "SalesforceData"
    },
    "sobjects":{
        "Contact": {
            "includeFields":["Id","FirstName","LastName","Email","Phone","Title"],
            "includeRelated":["Account"],
            "includeCustom":{"FullName": "{!FirstName} {!LastName}"}
        },
        "Account": {
            "includeFields":["Name","Type","Industry"],
            "includeRelated":["Owner","Opportunities"]
        },
        "Opportunity": {
            "includeFields":["Name","Amount"]
        },
        "User": {
            "includeFields":["Name","Email","Username","Manager.Name"]
        }
    }
}

Supported Parameters

rootElementName - The name to be given to the root element in the generated XML prefill data. Defaults to SFDCPrefillData. This is the optional parameter.

Object Type Definition

A single JSON configuration can support any number of Salesforce object types, thereby allowing the form to be prefilled with many different object types. For example, the same form may be prefilled from a contact record or a lead record.

The configuration for an object type must be contained in an attribute labeled with the name of that object type. Note the configuration below for the Account object:

"Account": {
    "includeFields":["Name","Type","Industry"]
}

Dealing with Complex Types

If you wish to prefill data from Salesforce that is contained in complex types (e.g. Addresses), you should configure the individual data sub-attributes in your prefill configuration. For example, if you want to prefill the Shipping Address from the Account object, your configuration should be similar to this:

{
    "sobjects":{
        "Account": {
            "includeFields":["Name","ShippingStreet","ShippingCity","ShippingState","ShippingPostalCode","ShippingCountry"]
        }
    }
}

The includeFields Directive (Required)

The includeFields directive is required for all object prefill definitions and allows you to explicitly specify the fields to be included in the prefill data with the following considerations:

  • The field list should be provided as a comma separated list of string litterals where each item specifies the field name, not the label of the field.
  • Parent and referential relationships can be leveraged by using the 'dot' notation to traverse the relationships by the name of the relationship (E.g. "includeFields": "FirstName,LastName,Owner.Name"). Note: if a child relationship is specified it will be ignored, but child relationships are supported in the includeRelated directive.
  • Include the Id field if you want to support form user edits to the object information. If the Id value is present when the competed submission is processed on its return to Salesforce, the delivery processor may use this Id to update the object according to the updates made in the form.

The includeRelated Directive (Optional)

The includeRelated directive is optional and allows you to specify related objects to include in the prefill data with the following considerations:

  • Specifying a related entity requires that the object type definition exists in the JSON configuration for that related entity.
  • The object type definition must specify the name of the object type, not the name of the relationship. As an example, consider the directive "includeRelated":"Owner". The relationship name is 'Owner' but the related entity is a 'User' so the JSON configuration must contain an object definition named 'User'.
  • Child relationships are supported, provided that the object is not itself a child of the primary prefill entity.

The includeCustom Directive (Optional)

  • The includeCustom directive is optional an allows you to specify custom fields to include in the prefill data with the following considerations:
  • Hard coded values may be used. E.g. "includeCustom":{"CampaignCode":"FF102"}
  • Field references to the object context may be used but the referenced fields must be specified in the includeFields directive. E.g. "includeCustom":{"FullName": "{!FirstName} {!LastName}"}

XML Prefill Data Generation

The TransactPrefillGenerator interprets the JSON configuration and generates the XML data used to prefill the form according to the following rules:

  • XML root element is always named 'SFDCPrefillData' unless an alternative root element name is specified.
  • Each sub-node within the root element represents a single Salesforce object or a list of objects
  • All fields specified in the includeFields or includeCustom directives will be included in the object node
  • Where a related field is specified in the includeFields directive (E.g. Manager.Name), that field will generated the parent object node in a containing element named according to the relationship
  • Where the includeRelated directive includes a parent or referencial relationship (E.g. "includeRelated":"Owner"), the object node for the related object will be added to the XML root node and named according to the relationship, as shown below.
  • <Owner>
        <Name>Jeff Johnson</Name>
        <Manager>
            <Name>Jenny Quack</Name>
        </Manager>
    </Owner>
  • Where the includeRelated directive includes a child relationship, a list container node will be added to the XML root node and named according to the relationship, each object node within the container will be named with the object type name, as shown below
  • <Opportunities>
        <Opportunity>
            <Name>Chicago City Store Displays</Name>
            <Amount>$50,000.00</Amount>
        </Opportunity>
        <Opportunity>
            <Name>San Francisco Mobile Signage</Name>
            <Amount>$28,000.00</Amount>
        </Opportunity>
    </Opportunities>

The following block illustrates an example of the XML prefill data produced by the generation engine:

<?xml version="1.0" encoding="UTF-8"?>
<SFDCPrefillData>
    <Contact>
        <Id>00390000015C9LBAA0</Id>
        <FirstName>Kristen</FirstName>
        <LastName>Akin</LastName>
        <Title>Director, Warehouse Mgmt</Title>
        <Phone>(434) 555-3100</Phone>
        <Email>[email protected]</Email>
        <FullName>Kristen Akin</FullName>
    </Contact>
    <Account>
        <Name>Volley Music</Name>
        <Type>Customer - Direct</Type>
        <Industry>Retail</Industry>
    </Account>
    <Owner>
        <Name>Jeff Johnson</Name>
        <Email>[email protected]</Email>
        <Username>[email protected]</Username>
        <Manager>
            <Name>Jenny Quack</Name>
        </Manager>
    </Owner>
    <Opportunities>
        <Opportunity>
            <Name>Chicago City Store Displays</Name>
            <Amount>$50,000.00</Amount>
        </Opportunity>
        <Opportunity>
            <Name>San Francisco Mobile Signage</Name>
            <Amount>$28,000.00</Amount>
        </Opportunity>
    </Opportunities>
    <User>
        <Name>Johny Lighning</Name>
        <Email>[email protected]</Email>
        <Username>[email protected]</Username>
        <Manager>
            <Name>Jack Sparrow</Name>
        </Manager>
    </User>
</SFDCPrefillData>

Custom Prefill Generators

Where the default prefill generator does not provide the level of control required, you may define your own prefill generator by developing an APEX class that implements the ITransactPrefillGenerator interface. To utilize your custom prefill generator, simply specify the class name in the relevant Prefill Generator record and any configuration required by the class.

global interface ITransactPrefillGenerator {
 
    /**
     * This function generates the prefill XML data based on the config provided.
     *
     * @param prefillObjectId The Id of the object to use for prefill generation
     * @param formPrefillConfig The string containing the generation config
     * @return The generated prefill XML data
     */
    String generatePrefillXml(Id entityId, String config);
}

Next, learn how to configure the Transact for Salesforce App UI in Salesforce