For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.