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 392 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.

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: 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 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2022 Joel Lipman .com. All Rights Reserved.