For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

ZohoCRM to ZohoBooks: Please ensure that the shipping_address has less than 100 characters.

What?
An article to note something I didn't realize I needed: How to address the above error and how to update a Shipping Address for a specific Sales Order in Zoho Books.

Why?
You might think the following request to create a Sales Order in Zoho Books would be enough:
copyraw
{
  "date": "2021-09-08",
  "zcrm_potential_id": "123456789012345678",
  "currency_code": "GBP",
  "reference_number": "Salespersons Test Reference",
  "terms": "These are our test terms and conditions",
  "customer_id": "234567890123456789",
  "payment_terms": 30,
  "salesperson_id": "345678901234567890",
  "line_items": [
    {
      "item_id": "456789012345678901",
      "discount": 0,
      "quantity": 1,
      "description": "A test product description"
    }
  ],
  "shipping_address": {
    "address": "Test Street",
    "street2": "Test Street 2",
    "city": "Test City",
    "state": "Test State",
    "zip": "Test Postal Code",
    "country": "Test Country"
  }
}
  1.  { 
  2.    "date": "2021-09-08", 
  3.    "zcrm_potential_id": "123456789012345678", 
  4.    "currency_code": "GBP", 
  5.    "reference_number": "Salespersons Test Reference", 
  6.    "terms": "These are our test terms and conditions", 
  7.    "customer_id": "234567890123456789", 
  8.    "payment_terms": 30, 
  9.    "salesperson_id": "345678901234567890", 
  10.    "line_items": [ 
  11.      { 
  12.        "item_id": "456789012345678901", 
  13.        "discount": 0, 
  14.        "quantity": 1, 
  15.        "description": "A test product description" 
  16.      } 
  17.    ], 
  18.    "shipping_address": { 
  19.      "address": "Test Street", 
  20.      "street2": "Test Street 2", 
  21.      "city": "Test City", 
  22.      "state": "Test State", 
  23.      "zip": "Test Postal Code", 
  24.      "country": "Test Country" 
  25.    } 
  26.  } 
However, if you try forcing the billing or shipping address in you should get the following error:
Please ensure that the shipping_address has less than 100 characters.

How?
If you get the above error, the community forums will advise you to get the ID of the Shipping Address... But let's say I don't know how to create a shipping address and retrieve its ID then here's the method I use:
  1. Create the sales order in ZohoBooks (either in Zoho Deluge or however you're doing it), then
  2. Retrieve the ID of the created Sales Order (captured in response)
  3. Update the Shipping Address on the Sales Order in Zoho Books using the API

The following is the code template I use but you will need to adapt it for your own system:
copyraw
// init (specify your own organization ID for Zoho Books)
v_BooksOrgID = 20210922122;
m_BooksCreateSO = Map();
// get CRM record details
r_SoDetails = zoho.crm.getRecordById("Sales_Orders", 012345678901234567);
// build up your map to send to ZohoBooks to create the Sales Order
m_BooksCreateSO.put("date",zoho.currentdate);
//
// push to ZohoBooks
r_CreateSO = zoho.books.createRecord("salesorders",v_BooksOrgID,m_BooksCreateSO,"ab_books");
// output response
info r_CreateSO;
// read response
if(!isnull(r_CreateSO.get("salesorder")))
{
	v_SalesOrderID = r_CreateSO.get("salesorder").get("salesorder_id");
	//
	v_AddressIndex = 0;
	m_ShippingAddress = Map();
	// set field api names that we will read from and write to
	l_CrmShippingAddress = {"Shipping_Street","Shipping_Street_2","Shipping_City","Shipping_State","Shipping_Code","Shipping_Country"};
	l_BooksShippingAddress = {"address","street2","city","state","zip","country"};
	// loop through the CRM Sales Order address fields and build map of address to Books
	for each  v_AddressPart in l_CrmShippingAddress
	{
		m_ShippingAddress.put(l_BooksShippingAddress.get(v_AddressIndex),ifnull(r_SoDetails.get(v_AddressPart),""));
		v_AddressIndex = v_AddressIndex + 1;
	}
	// check that there was something to actually update rather than wasting an API call
	if(m_ShippingAddress.size() > 0)
	{
		// endpoint TLD is EU for Europe DC and COM for US DC
		v_Endpoint = "https://books.zoho.eu/api/v3/salesorders/"+v_SalesOrderID+"/address/shipping?organization_id=" + v_BooksOrgID;
		// saw this in the documentation example so will hopefully do what it says
		m_ShippingAddress.put("is_one_off_address",true);
		m_ShippingAddress.put("is_update_customer",false);
		// send the request via API (change connection name to your own)
		r_UpdateSO = invokeurl
		[
        	url: v_Endpoint
            type: PUT
            parameters: m_ShippingAddress.toString()
            connection: "joels_connector"
		];
		info r_UpdateSO;
	}	
}
  1.  // init (specify your own organization ID for Zoho Books) 
  2.  v_BooksOrgID = 20210922122
  3.  m_BooksCreateSO = Map()
  4.  // get CRM record details 
  5.  r_SoDetails = zoho.crm.getRecordById("Sales_Orders", 012345678901234567)
  6.  // build up your map to send to ZohoBooks to create the Sales Order 
  7.  m_BooksCreateSO.put("date",zoho.currentdate)
  8.  // 
  9.  // push to ZohoBooks 
  10.  r_CreateSO = zoho.books.createRecord("salesorders",v_BooksOrgID,m_BooksCreateSO,"ab_books")
  11.  // output response 
  12.  info r_CreateSO; 
  13.  // read response 
  14.  if(!isnull(r_CreateSO.get("salesorder"))) 
  15.  { 
  16.      v_SalesOrderID = r_CreateSO.get("salesorder").get("salesorder_id")
  17.      // 
  18.      v_AddressIndex = 0
  19.      m_ShippingAddress = Map()
  20.      // set field api names that we will read from and write to 
  21.      l_CrmShippingAddress = {"Shipping_Street","Shipping_Street_2","Shipping_City","Shipping_State","Shipping_Code","Shipping_Country"}
  22.      l_BooksShippingAddress = {"address","street2","city","state","zip","country"}
  23.      // loop through the CRM Sales Order address fields and build map of address to Books 
  24.      for each  v_AddressPart in l_CrmShippingAddress 
  25.      { 
  26.          m_ShippingAddress.put(l_BooksShippingAddress.get(v_AddressIndex),ifnull(r_SoDetails.get(v_AddressPart),""))
  27.          v_AddressIndex = v_AddressIndex + 1
  28.      } 
  29.      // check that there was something to actually update rather than wasting an API call 
  30.      if(m_ShippingAddress.size() > 0) 
  31.      { 
  32.          // endpoint TLD is EU for Europe DC and COM for US DC 
  33.          v_Endpoint = "https://books.zoho.eu/api/v3/salesorders/"+v_SalesOrderID+"/address/shipping?organization_id=" + v_BooksOrgID; 
  34.          // saw this in the documentation example so will hopefully do what it says 
  35.          m_ShippingAddress.put("is_one_off_address",true)
  36.          m_ShippingAddress.put("is_update_customer",false)
  37.          // send the request via API (change connection name to your own) 
  38.          r_UpdateSO = invokeUrl 
  39.          [ 
  40.              url: v_Endpoint 
  41.              type: PUT 
  42.              parameters: m_ShippingAddress.toString() 
  43.              connection: "joels_connector" 
  44.          ]
  45.          info r_UpdateSO; 
  46.      } 
  47.  } 

Source(s):
Category: Zoho :: Article: 772

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.