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.

Zoho Inventory: Mark a package slip as delivered and shipped

What?
A quick article on a code snippet to mark a package as shipped and delivered in Zoho Inventory.

Why?
As usual, any task like this that takes me longer than an hour, I'd like to document for future use. The use-case is the client has their own delivery drivers and want them to mark a sales order & package as shipped and delivered.

How?
Here's a code snippet that works for me.  It is triggered when a user ticks a decision box in Zoho Creator (on iPad displays as an on/off switch).  My connection here called "jl_inventory" has the minimum required scopes:
  • ZohoInventory.salesorders.READ
  • ZohoInventory.packages.READ
  • ZohoInventory.shipmentorders.CREATE
  • ZohoInventory.shipmentorders.READ
copyraw
//
// init (put your own ZohoBooks/ZohoInventory Org ID
v_BooksOrgID = 123456789;
//
// check the form was ticked and there is a package ID specified
if(input.Mark_as_Complete && input.Zoho_Package_ID != "")
{
	v_PackageID = input.Zoho_Package_ID;
	r_PackageSlip = zoho.inventory.getRecordsByID("packages",v_BooksOrgID.toString(),v_PackageID,"ab_inventory");
	if(r_PackageSlip.get("package") != null)
	{
		if(r_PackageSlip.get("package").get("salesorder_id") != null)
		{
			v_SalesOrderID = r_PackageSlip.get("package").get("salesorder_id");
		}
		if(r_PackageSlip.get("package").get("shipment_order") != null)
		{
			v_ShipmentID = r_PackageSlip.get("package").get("shipment_order").get("shipment_id");
			//
			// if blank then create one
			if(v_ShipmentID == "")
			{
				m_Params = Map();
				m_Params.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
				m_Params.put("delivery_method","My_Own_Drivers");
				m_Params.put("delivered_date",zoho.currentdate.toString("yyyy-MM-dd HH:mm"));
				m_Params.put("tracking_number","N/A");
				l_UrlParams = List();
				l_UrlParams.add("salesorder_id=" + v_SalesOrderID);
				l_UrlParams.add("package_ids=" + v_PackageID);
				l_UrlParams.add("is_delivered=true");
				l_UrlParams.add("organization_id=" + v_BooksOrgID);
				v_Url = "https://inventory.zoho.com/api/v1/shipmentorders?" + l_UrlParams.toString("&");
				r_CreateShipment = invokeurl
				[
					url :v_Url
					type :POST
					parameters:m_Params.toString()
					connection:"jl_inventory"
				];
				info "Created Shipment: ";
				info r_CreateShipment;
				if(r_CreateShipment.get("shipment_order") != null)
				{
					if(r_CreateShipment.get("shipment_order").get("shipment_id") != null)
					{
						v_ShipmentID = r_CreateShipment.get("shipment_order").get("shipment_id");
					}
				}
			}
			//
			// maybe one is either used or created
			if(v_ShipmentID != "")
			{
				v_Url = "https://inventory.zoho.com/api/v1/shipmentorders/" + v_ShipmentID + "/status/delivered?organization_id=" + v_BooksOrgID;
				r_Delivered = invokeurl
				[
					url :v_Url
					type :POST
					connection:"jl_inventory"
				];
				info "Marked as Delivered:";
				info r_Delivered;
			}
		}
	}
}
  1.  // 
  2.  // init (put your own ZohoBooks/ZohoInventory Org ID 
  3.  v_BooksOrgID = 123456789
  4.  // 
  5.  // check the form was ticked and there is a package ID specified 
  6.  if(input.Mark_as_Complete && input.Zoho_Package_ID != "") 
  7.  { 
  8.      v_PackageID = input.Zoho_Package_ID; 
  9.      r_PackageSlip = zoho.inventory.getRecordsByID("packages",v_BooksOrgID.toString(),v_PackageID,"ab_inventory")
  10.      if(r_PackageSlip.get("package") != null) 
  11.      { 
  12.          if(r_PackageSlip.get("package").get("salesorder_id") != null) 
  13.          { 
  14.              v_SalesOrderID = r_PackageSlip.get("package").get("salesorder_id")
  15.          } 
  16.          if(r_PackageSlip.get("package").get("shipment_order") != null) 
  17.          { 
  18.              v_ShipmentID = r_PackageSlip.get("package").get("shipment_order").get("shipment_id")
  19.              // 
  20.              // if blank then create one 
  21.              if(v_ShipmentID == "") 
  22.              { 
  23.                  m_Params = Map()
  24.                  m_Params.put("date",zoho.currentdate.toString("yyyy-MM-dd"))
  25.                  m_Params.put("delivery_method","My_Own_Drivers")
  26.                  m_Params.put("delivered_date",zoho.currentdate.toString("yyyy-MM-dd HH:mm"))
  27.                  m_Params.put("tracking_number","N/A")
  28.                  l_UrlParams = List()
  29.                  l_UrlParams.add("salesorder_id=" + v_SalesOrderID)
  30.                  l_UrlParams.add("package_ids=" + v_PackageID)
  31.                  l_UrlParams.add("is_delivered=true")
  32.                  l_UrlParams.add("organization_id=" + v_BooksOrgID)
  33.                  v_Url = "https://inventory.zoho.com/api/v1/shipmentorders?" + l_UrlParams.toString("&")
  34.                  r_CreateShipment = invokeUrl 
  35.                  [ 
  36.                      url :v_Url 
  37.                      type :POST 
  38.                      parameters:m_Params.toString() 
  39.                      connection:"jl_inventory" 
  40.                  ]
  41.                  info "Created Shipment: "
  42.                  info r_CreateShipment; 
  43.                  if(r_CreateShipment.get("shipment_order") != null) 
  44.                  { 
  45.                      if(r_CreateShipment.get("shipment_order").get("shipment_id") != null) 
  46.                      { 
  47.                          v_ShipmentID = r_CreateShipment.get("shipment_order").get("shipment_id")
  48.                      } 
  49.                  } 
  50.              } 
  51.              // 
  52.              // maybe one is either used or created 
  53.              if(v_ShipmentID != "") 
  54.              { 
  55.                  v_Url = "https://inventory.zoho.com/api/v1/shipmentorders/" + v_ShipmentID + "/status/delivered?organization_id=" + v_BooksOrgID; 
  56.                  r_Delivered = invokeUrl 
  57.                  [ 
  58.                      url :v_Url 
  59.                      type :POST 
  60.                      connection:"jl_inventory" 
  61.                  ]
  62.                  info "Marked as Delivered:"
  63.                  info r_Delivered; 
  64.              } 
  65.          } 
  66.      } 
  67.  } 

Error(s) Encountered
  • {"code": 4,"message": "Invalid value passed for salesorder_id"}: Not sure about what ended up fixing this one. I think I converted the sales order to an invoice and created a package slip for it. The invoice was then sent (payment=unpaid). Not sure which fixed this.
  • {"code": 4,"message": "Invalid value passed for JSONString"}: Quick fix by settings the parameters in the invokeUrl to a string m_Params.toString()
Category: Zoho :: Article: 816

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.