# Account Owner Mapping

## Account Owner Mapping

**Requirement:** Map the Salesforce Account Owner with the REP field on the Customer level in QuickBooks.

**Solution:** Before mapping, ensure that the user **Alias** name present in Salesforce should also be present in QuickBooks field named **REP** in the customer object.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FnlnGJynWPAnyctAXsBTF%2Fimage.png?alt=media&#x26;token=56c11a14-9176-4a6a-ba3a-5b807277021e" alt=""><figcaption><p>Alias name in Salesforce</p></figcaption></figure>

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FmoHkLrt6vqBZTC6YnfQn%2Fimage.png?alt=media&#x26;token=8f1804a0-7bd2-4c9b-a3c9-2048aa6cb5ab" alt=""><figcaption><p>REP field where Alias name is to be provided</p></figcaption></figure>

## Steps to update the DBSync mappings&#x20;

1\. Add the *Account.Owner.Alias* API name in the DBSync query.

{% code overflow="wrap" fullWidth="true" %}

```
select Account.Phone,Account.Name,AVSFQB__Primary_Contact__r.FirstName,AVSFQB__Primary_Contact__r.LastName,Account.BillingStreet,Account.BillingCity,Account.BillingCountry,Account.BillingPostalCode,Account.BillingState,Account.Accounting_Email_Address__c,AVSFQB__Primary_Contact__r.Email,Account.Fax,Account.Price_Level__c,Opportunity.Today_s_Date__c,Account.ShippingStreet,Account.ShippingCity,Account.ShippingCountry,Account.ShippingPostalCode,Account.ShippingState,Name,AVSFQB__QuickBooks_Id__c,AVSFQB__Billing_Address__c,AVSFQB__Billing_City__c,AVSFQB__Billing_Country__c,AVSFQB__Billing_Zip__c,AVSFQB__Billing_State__c,Estimated_Ship_Date__c,AVSFQB__PO_Number__c,Owner.Alias,AVSFQB__Shipping_Address__c,AVSFQB__Shipping_City__c,AVSFQB__Shipping_Country__c,AVSFQB__Shipping_Zip__c,AVSFQB__Shipping_State__c,CloseDate,Id,Account.AVSFQB__QuickBooks_Id__c,Account.Id,Account.Owner.Alias,(select Id,Description,PricebookEntry.Product2.Bin__c,PricebookEntry.Product2.Site__c,ProductCode,PricebookEntry.Product2.AVSFQB__QuickBooks_ItemType__c,Quantity,UnitPrice,PricebookEntry.Product2.Name from OpportunityLineItems) FROM Opportunity where  Opportunity.AVSFQB__Generate_Object__c='SalesOrder' and AVSFQB__Products_Count__c > 0
```

{% endcode %}

2\. In the Transform\&Write action, click **Map** for the 1st action (customer creation).

3\. Update the mappings for SalesRepRef field by ***VALUE("Account/Owner/Alias")***

4. **Save** and **close**. Save the flow. The above changes will work only for the newly created accounts in Salesforce. For the changes to reflect in the historical accounts, create a new transform\&write action(for Update operation). The steps mentioned below are used to create an update operation for updating the account owner to customers who have already synced to QuickBooks.
5. Select the appropriate target connector, operation, and target object.&#x20;
6. Update the mappings as shown below.

```
Process Records When= IF(ISEMPTY(VALUE("Account/AVSFQB__Quickbooks_Id__c")), "false", "true")
```

```plaintext
JobTypeRef 
ListID= VALUE("Account/AVSFQB__Quickbooks_Id__c")
```

```
SalesRepRef
FullName: VALUE("Account/Owner/Alias")
```

7. **Save** and **Close**. Save the flow.

{% hint style="info" %}
Note: In QuickBooks, the REP field has a character limit of 5. In Salesforce, we need to ensure that the Alias does not exceed 5 characters.
{% endhint %}
