# NetSuite: Sync Customer Addresses by Address Label - workaround

**URL:** <https://connective.celigo.com/t/netsuite-sync-customer-addresses-by-address-label-workaround/1016>\
**Category:** Integrator.io\
**Tags:** export, transformation, import, lookup, netsuite\
**Created:** [October 18, 2024, 7:43pm UTC](https://connective.celigo.com/t/netsuite-sync-customer-addresses-by-address-label-workaround/1016 "2024-10-18T19:43:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![troythompson](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@troythompson](https://connective.celigo.com/u/troythompson)\
**Post date:** [October 18, 2024, 7:43pm UTC](https://connective.celigo.com/t/netsuite-sync-customer-addresses-by-address-label-workaround/1016/1 "2024-10-18T19:43:18Z")

</div>

**Scenario** : Customer address data in an external system needs to be refreshed in NetSuite, based on the Address Label. The Customer records exist in both systems, and no new Customer records should be created in this scenario. Customer Addresses must be updated or created, using the Address Label as if it were the key to the Address.

**Issue:** NetSuite treats addresses as a sublist under the Customer record; native Celigo Import “Add or Update” may add a _Customer_ record rather than adding a new _Address_. There is no direct Import option into an Address record. NetSuite permits duplicate Address Labels and does not treat labels as unique keys.

**Workaround:** Perform a lookup to get the existing Address ID; configure the Import mapping for the ID to _Discard if Empty_. This prevents duplicate addresses from being created, and creates Addresses cleanly during a Customer “Update”.

**Details:** After setting up the export and lookup steps, ensure that the Customer Internal ID and Address Label have the desired values.

1. Assumed: the flow has generated or exported a desired Address Label, _unique per Customer_.
2. In the step where the address fields are being set in Transform, include a field for the Address Internal ID, set to a hard-coded empty string value (input field Settings button, then Field transformation type _Hard-coded_ then _How would you like to hard-code the value? Use empty string as default value_.
3. Create a Customer saved search in NetSuite including the Customer Internal ID, Address Label, and Address Internal ID fields. 
4. Add a Lookup on the NetSuite Customer saved search, filtered by Customer Internal ID and Address Label (For _Additional Search Criteria_ include _Customer Internal ID any of {{internalid}}_ and _Address Label is {{YourGeneratedLabel}}_.)
5. In the Lookup results mapping, include the Address Internal ID, _overwriting_ the default empty string value set earlier. This overwrites with an ID, if the label _already exists_ for the Customer.
6. Create an Import to NetSuite **Customer** configured as follows:
  1. Operation: Update
  2. How we can find existing records: _InternalId is Internal ID_.

7. Import mapping: Configure the field mapping as follows:
  1. Customer Internal ID to Internal ID.
  2. Address Internal ID to Address : ID; select the gear icon and pick _ **Discard if empty** _. This is important.
  3. All other Address fields (Label, address lines, City, State, Postal Code, etc) map as usual.

**Result:** The flow will correctly “add or update” the Address details under the Customer, using Address Label as if it were a unique key.

**Caveat and WARNING:** This flow makes an assumption that differs from NetSuite's default behavior. NetSuite permits duplicate Address Labels, but this flow treats the Address Labels as if they are unique. _ **This may cause unexpected side effects!** _ Ensure that the Address Labels generated in the Export phase are unique per Customer to prevent collisions. This may cause issues if a Customer has multiple duplicate Address Labels already.
