Re: Feedback - Updating existing Company / Location Records

Feedback - Updating existing Company / Location Records

james148
Shopify Partner
27 0 10

Inserting new companies using the InsertCompany mutation - absolutely fine.

Updating existing company records with existing location records - an absolute mess! Did the update team responsible look at what the inset did and think 'simplicity, ease of use - that's not for us'?

When creating a new company, you can create it with a default location, which works perfectly. I will assume that most (not all) companies needing B2B will want a company with a single location and your API has reflected this requirement.

The problems arise when attempting to update that default location!

  • Number of API calls - To create the company is a single API request, to do the equivalent on an existing Company with default Location record could be up to 7 or 8 separate API requests (updating company, update location, update both address, update company contact, update tax registration and exemption).
  • Addresses 1 - If the billing and shipping addresses are different then you need to issue two separate API calls. The location record (to the best of my knowledge) only has a shipping and billing address.
  • Addresses 2 - You have different flag to signify the billing and shipping address are different - on insert it's  billing_same_as_shipping, on the companyLocationAssignAddress mutation you need to send a list of values to addressTypes.
  • companyLocationCreateTaxRegistration & companyLocationAssignTaxExemptions - Why aren't these included in the locationUpdate? It takes now two separate API calls to update these and two more to remove (just accept a null to remove).

Thanks

Replies 3 (3)

Liam
Community Manager
3108 341 879

Hi James,

 

Thanks for describing your experience with making updates via the API when there's multiple existing companies, I'm in touch with the product team that owns this space and I've communicated the issues you're seeing around efficiency and consistency. I will update here with their response.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Liam
Community Manager
3108 341 879

Hi James,

 

Our team are curious what is the use case that requires you to create a company with a default location, and then update the location. You can specify the location details in the CompanyCreate mutation and it should create everything in one shot. 

 

The product team wondering if this workflow might work for you: Instead of updating, create a new companyLocation with companyLocationCreate and delete the existing one with companyLocationsDelete?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

james148
Shopify Partner
27 0 10

Liam, many thanks for the reply. To provide some background we provide integration with ERP systems (Sage and Acumatica though the scenario could apply to Dynamics, or any other ERP).

 

If we are passing up 'company' records to Shopify, the likely source will be Customers in the ERP, and most likely we would to create:

 

1. Company Record

2. Location

3. Customer

 

This would be a 1:1:1 relationship - The CreateCompany mutation allows us to create the Company, Default Location Contact, etc.

 

As an aside there is value with having multiple locations to a single company (but we need to do the same dance).

 

Obviously the customer has it's own address (an artifact of pre-Company/B2B times), but the Location has its own Billing and Shipping. 

 

If there is a change in the address in the ERP (particularly billing) we want to be able to update the address really on both the customer, but also the Location to keep things in sync (and this is where it becomes difficult). The Billing and Shipping addresses (to the best of our knowledge) each require separate API requests.

 

If we need to update a contact record, we need to send another API request. If the Tax Registration is added (rarely changed) yet another request.

 

Yes you could do companyLocationsDelete  and companyLocationCreate but you then need to reassociate a customer with the companyContactAssignRole so they can place an order. What happens if the customer is ordering and you make this change (a likely race condition)?