Learning Objective:-

**Introduction:- **

This tutorial explains what formula is and why do we need it. It also describes the generating of the IStructure which is correlating with mapping.

**What is the formula?**

The Formula is a complex mapping rule – for example, a combination of source fields or a combination of functions and source fields mapped to one sObject field. we can do formula mapping using different functions.

**Pre-requisite:-**

Before using a formula in mapping, you must have an interface. To create, delete and edit interface, you need to do in Salesforce. This document is skipping the part where to create Integration and Interface. If you want to know how to create them, please look for the document (SKYVVA Integration/ Interface).

**The creation of IStructure:-**

**There are 5 ways to generate IStructure:**

– Generate from sObject in field

– Manually created

– Upload from File

– Generate from Message Type

– Generate from SOQL Query (Outbound)

**Description**:

**1**. Generate from sObject in the field: The Structure is generated from Source/Target of Salesforce object. In case you don’t have your own Structure, we create this type of Istructure to make things easier for you.

**2**. Manually created: You create IStructure field one by one by yourself.

**3**. Upload from File: You have your own source (Structure) and upload it to Salesforce. The source is a file: CSV and XML.

**4**. Generate from Message Type: Upload IStructure in Repository then create Message type from it.

**5**. Generate from SOQL Query: To filter for fields of Salesforce object.

Note: There are 4 ways to generate IStructure for Inbound and 5 ways for Outbound Interface.

**Inbound Mapping:-**

For the inbound interface, the Mapping screen is like the screenshot below. The screen divided into two which are Source and Target. On the Source side, the structure of the field is from external source weather the target side contains the structure of the field from the Salesforce object.

**Outbound Mapping:-**

As you can see from the screen below, this is an outbound interface. The screen divided into two as an inbound interface, however, the Source side here is containing the structure of the fields of Salesforce sObject and the Target side contains the fields of an external source.

**Using a formula in mapping:-**

This Istructure is generated from upload File. This part is explained about mapping in Salesforce using formula. There are lots of different formula you can choose to do in mapping, however, there is two formula which will be explained here in this document. These formulas are VLOOKUP and IF. The following examples will demonstrate to you how to use each formula in mapping

Mapping In Account Interface:

Mapping In Contact Interface:

**VLOOKUP Formula:-**

VLOOKUP is one of SKYVVA formula function which is better than the function of Salesforce that can retrieve the value from both standard and custom objects, different fields, e.g. Id and Name, etc. with many conditions. To add any formula in mapping, you have to check on the Formula box at the right as in the picture below and choose any kind of function.

Here is the syntax of VLOOKUP:

“VLOOKUP(Standard/CustomObjectName,FieldToRetrieve,FieldCondition1,Condition1,Fiel dCondition2,Condition2,…)”

The popup window below will show when you check the flag and click on the line.

– Choose function = VLOOKUP then click Insert Select Function button

– Enter the values

– Clicks on Test Formula to see output if it is true or failed than Save.

Note: If the output is failed, it means that your formula is incorrect.

In conclusion, after you map all fields, do the formula and choose the External ID, please Save. Just in case you forget to save, all your Data Mapping will be lost.

**IF Formula:-**

IF is also one of formula to use in mapping. IF function is using to test for or evaluate certain conditions, and then react differently depending on whether the test was TRUE or FALSE. The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE result. You can use it to test for specific conditions or more than one.

Here is the syntax:

**IF(logical_test, value_if_true, value_if_false)**

This section will only focus on how to use formula, so the steps will show at Data Mapping Editor where you have to check the flag on Formula box and click the line in order to get the popup window.

– Choose function = IF then click Insert Select Function button

– Enter the values

– Clicks on Test Formula to see output if it is true or failed than Save.

**Note:- **

**If the output is failed, it means that your formula is incorrect.****In conclusion, after the mapping, please Save it. Otherwise, all your Data Mapping will be lost.**