# Product Hierarchy in QuickBooks and Salesforce

## Integration from QuickBooks to Salesforce

If you use the Product Hierarchy in QuickBooks, then Salesforce needs to be updated to support the Product Hierarchy.&#x20;

Suppose **Software** is the parent item and **Accounting Module** and **CRM Module** are child items under it in QuickBooks. When you generate an invoice in QuickBooks using these items, the item name for the parent **Software** remains **Software**, while the child items appear with the parent prefix, such as **Software: Accounting Module** and **Software: CRM Module**. If this invoice is moved to Salesforce Opportunity, then, the product is migrated with the parent Name into Salesforce.

1. To make changes, navigate to [https://login.salesforce.com](https://login.salesforce.com/). Enter your Salesforce **Username** and **Password**. Then, click **Login**.

{% hint style="info" %}
**NOTE:** The user logging in should have administrative privileges to make changes to the Salesforce instance.
{% endhint %}

2. Go to **Setup** **>** **Customize** **>** **Products** **>** **Fields** and click on **New** in Products Custom Fields and Relationships.
3. Select **Text** in the Next page and click **Next**. Enter Field Label as QuickBooksName, Length as 255, and Field Name as QuickBooksName. Click **Next**.
4. In the next screen, select field-level security for profiles and click **Next**. Check the **Add Field** checkbox. Then, check the Page Layouts you want to add it to. Click **Save.**
5. Go to **Setup** **>** **Customize** **>** **Products** **>** **Page Layouts**. Click on Edit for Product Layout.
6. Add **QuickBooks Name** fields to the Page Layout. Click Save.
7. Log in to your DBSync account and navigate to the DBSync project page.
8. Ensure that the Salesforce and QuickBooks connectors are validated.&#x20;
9. Click on Projects. Select and open a relevant project. Select and open the relevant Task. You will see a list of available flows.
10. Open the flow for syncing **ItemService to Product.** Open the ma&#x70;**.**
11. Add the mapping **QuickBooksName\_\_c = VALUE("FullName")** and save the mapping.
12. Similarly, add the above mapping as follows to complete the Product Hierarchy setup:

* ItemInventoryToProduct
* ItemNonInventoryToProduct
* ItemDiscountToProduct
* ItemOtherChargesToProduct

Now, your Salesforce is configured to handle the Product Hierarchy of QuickBooks.

## Integration from Salesforce to QuickBooks <a href="#producthierarchyinquickbooksandsalesforce-integrationfromsalesforcetoquickbooks" id="producthierarchyinquickbooksandsalesforce-integrationfromsalesforcetoquickbooks"></a>

If you have a Parent-Child relationship for Products in Salesforce, then the following changes need to be made to the mappings.

1. Log in to your DBSync account.
2. Ensure that Salesforce and QuickBooks connectors are validated.
3. Click on Projects. Select and open the relevant Project. Navigate to the flow page. You will see a list of available flows.
4. Open the flow **Opportunity To Invoice** and open the map for **ItemService**.&#x20;
5. Find the target field **"ItemServiceAddRq/ItemServiceAdd/Name".**  Then, replace the source by copy-pasting the following:

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemService"),
RSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")
```

{% endcode %}

6. Add the mapping where target field = "**ItemServiceAddRq/ItemServiceAdd/ParentRef/FullName**" and source field as the following:

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemService"),
(IF(VALUE("PricebookEntry/Product2/Name").contains(":"),
LSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")),"")
```

{% endcode %}

7. Similarly, open the mapping for **ItemInventory**.
8. Find the target field **"ItemInventoryAddRq/ItemInventoryAdd/Name"** and replace the source code by copy-pasting the following:

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemInventory"),
RSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")
```

{% endcode %}

9. Open the mapping for **ItemNonInventory.**
10. Find the target field **"ItemNonInventoryAddRq/ItemNonInventoryAdd/Name".**  Replace the source code by copy-pasting the following: Add the mapping where target field = "**ItemInventoryAddRq/ItemInventoryAdd/ParentRef/FullName**" **and** source field as the following:

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemInventory"),
(IF(VALUE("PricebookEntry/Product2/Name").contains(":"),
LSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")),"")
```

{% endcode %}

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemNonInventory"),
RSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")
```

{% endcode %}

11. Add the mapping where target field = "**ItemNonInventoryAddRq/ItemNonInventoryAdd/ParentRef/FullName**" **and** source field as the following:

{% code overflow="wrap" %}

```
IF(EXACT(VALUE("PricebookEntry/Product2/AVSFQuickBooks__QuickBooks_ItemType__c"),"ItemNonInventory"),
(IF(VALUE("PricebookEntry/Product2/Name").contains(":"),
LSPLIT(VALUE("PricebookEntry/Product2/Name"),":"),"")),"")
```

{% endcode %}

&#x20;The above example illustrates Product Hierarchy mapping for **OpportunityToInvoice** state. Based on the transaction you use, a similar procedure can be followed for other transaction workflows like **OpportunityToEstimate, OpportunityToSalesOrder, OpportunityToSalesReceipt,** and **OpportunityToCreditMemo**.
