Smartform field mapping
A field mapping copies the answers of a finished Smartform into Salesforce records. You define the mapping once in a visual editor, keep versions of it, and run it from a Flow. No Apex is needed.
You build mappings on the Smartforms to Salesforce Mapping tab of The Configuration screen.
How it works
- A mapping is a named set of rules for one Smartform. It has numbered versions, and only the active version runs.
- An object mapping says how to fill one kind of Salesforce record, for example
accountfor an Account andcontact1for a Contact. - A field mapping connects one Smartform property to one Salesforce field. Its Transformation decides how the value is found.
| Transformation | What it does |
|---|---|
| None | Copies the answer as it is. |
| Lookup | Fills a lookup field with the id of a parent record. You name the Source Object Mapping the id belongs to. When the mapping runs from a Flow, the id comes from the Parent Record ID input of the action. |
| Constant | Always sets the Constant Value you enter. |
You can also give a Default Value that is used when the Smartform property is empty.
Each object mapping fills one record. When you run a mapping from a Flow, one call of the action runs one object mapping, so a flow that creates several records calls the action once for each.
Create a mapping
- On the Smartforms to Salesforce Mapping tab, choose the Smartform Template the mapping is for.
- Click Create New Mapping.
- Enter a Mapping Name and a Mapping API Name and click Create. The API name can only contain letters, digits and underscores, and Salesforce suggests one from the name. A Flow refers to the mapping by its API name.
- Click Create New Object Mapping, enter an Object Mapping Name such as
account, choose the Salesforce Object Name and click Create. Repeat for every kind of record you want to create. - Open an object mapping and click Add Field Mapping. Choose the Smartform Property and the Salesforce Field, choose a Transformation and fill in what it needs. Click Save. A field that Salesforce requires is marked Required. Salesforce warns you if the same field is mapped twice, or if the types of the Smartform property and the Salesforce field do not fit together.
- Click Save on the mapping.
To change the name, API name or description of a mapping later, click Edit Mapping Properties.
Versions
Change a mapping safely by saving a new version instead of overwriting the one that runs.
- Select the mapping in Select Mapping and the Version you want to start from.
- Make your changes.
- Click Save as New Version and, if you like, add a Description for new version. Plain Save overwrites the version you opened.
- When the new version is ready, click Activate This Version.
Only the active version runs, so a Flow keeps using the old rules until you activate the new version.
Test a mapping
- Choose a Smartform Template and then a Smartform Webhook, which is one form of that template that was sent from Salesforce. Its answers are the test data.
- Open an object mapping and click Test Run.
- The table shows, for each field, its Status, the Salesforce Field, the Input Value from the form, the Mapped Value, and a Message.
Salesforce reports Record insert test passed successfully. when the record could be created, or Record Insert Failed with the reason. The test does not keep the record.
Use a mapping in a Flow
In Flow Builder, add the action Apply Smartform Field Mapping. It is usually used in a flow that starts when a Smartform finishes, see the platform events in the Smartforms Apex API.
| Input | Meaning |
|---|---|
| Mapping Name | The API name of the mapping. The active version is used. |
| Object Mapping Name | The object mapping to run, for example account. |
| Smartform Record ID | The id of the Smartform webhook record that holds the answers. |
| Target Record ID | Optional. The id of an existing record to update instead of creating a new one. |
| Parent Record ID | Optional. The id of a parent record, used by Lookup transformations. |
| Insert Record | true saves the record in the action. false only returns the record, and your flow saves it with a Create Records or Update Records element. |
| Output | Meaning |
|---|---|
| Success | Whether the mapping worked. |
| Record ID | The id of the created or updated record. It is only set when Insert Record is true, or when you gave a Target Record ID. |
| Mapped Record | The record that was filled in. |
| Error Message | The reason, when the mapping failed. |
| Mapped Fields | The number of fields that were filled in. |
If there is no active version of the mapping, the action fails with Active mapping not found and the name you gave.