Tip #4.1 Auto-creating package and shipment records for your offline sales orders

Tip #4.1 Auto-creating package and shipment records for your offline sales orders

Hello,


Hope this post finds you in good health.
Last week we saw how we could automate item weight calculation for your orders. This week we will go a step further and see how you can automate the process of creating packages and shipments for your sales orders. 

To make it easier for the reader, this post has been split into two. Part 1 or tip #4.1 will tell you how you can auto-create package and shipment records in Zoho Inventory for your offline orders while tip #4.2 or part 2 will tell you how to do the same for online orders.

Who is this for?

Any business that ships goods as soon as an order is made and has very less time on their hands for paperwork (same day shipments using a single carrier/by self).


How does this work? 

It all begins with a sales order draft inside of Zoho Inventory. As soon as you email the sales order to a client or manually mark it as confirmed, the system uses this status change as a trigger for creating a package record (with all of the items on your sales order). Once this is done, the system will record a manual shipment record within the system against a preset shipping medium (which can be configured by you as you write the custom function into Zoho Inventory). 

Now, let's see how we can write this custom function for your business.

Setting up the custom function:

Log in to your Zoho account and click on this link to generate an Auth Token which is required to make this work.
  • Open your Zoho Inventory organization.

  • Navigate to Settings using the gear icon from the top-right corner.

  • Select Automation from the sidebar. Now click on the button adjacent to +New Workflow Rule.

  • Out of the four options from the drop-down, select Custom Functions.

  • Now let's add a name for this workflow rule and make sure that there are no spaces between words.

  • Select Sales Orders against module.

  • Add a description if you need one.

  • Now, the workflow type is going to be Event Based.

  • The condition to set shall be, "When a Sales Order is created".

  • And, for the trigger, it will be "When Sales Order status is Confirmed".

  • Now copy and paste this code snippet into the deluge pane:

salesorderID = salesorder.get("salesorder_id"); 

salesorderdate = salesorder.get("date").toDate();

organizationID = organization.get("organization_id");

authtoken = "Copy and paste your authtoken here";

mapper = Map();

customerID = salesorder.get("customer_id").toString();

//package_number = salesorder.get("salesorder_number").replaceFirst("SO","PA");

//mapper.put("package_number",package_number);

mapper.put("customer_id",customerID);

mapper.put("date",salesorderdate);

lineItems = salesorder.get("line_items").toList();

newLineItems = List();

for each lineItem in lineItems

{

lineItemMap = Map();

solineitemID = lineItem.get("line_item_id");

lineItemMap.put("so_line_item_id",solineitemID);

quantity = lineItem.get("quantity");

lineItemMap.put("quantity",quantity);

newLineItems.add(lineItemMap);

}

mapper.put("line_items",newLineItems);

jsonString = Map();

jsonString.put("JSONString",mapper);

response = invokeurl

[

url :"https://inventory.zoho.com/api/v1/packages?authtoken=" + authtoken + "&salesorder_id=" + salesorderID + "&organization_id=" + organizationID

type : POST

parameters:jsonString

];

info mapper;

info response.toMap();

//shipment

pack=response.get("package");

packid=pack.get("package_id");

ship=Map();

ship.put("date",salesorderdate);

ship.put("delivery_method","dhl"); //REPLACE WITH SHIPPING CARRIER NAME OR DELIVERY BY SELF

jsons=Map();

jsons.put("JSONString",ship);

resp = invokeurl

[

url: "https://inventory.zoho.com/api/v1/shipmentorders?package_ids="+packid+"&salesorder_id=" +salesorderID+ "&authtoken="+authtoken+"&organization_id=" + organizationID

type: POST

parameters: jsons

];

info resp.toMap().get("message");


  • Copy and replace your authtoken number with the text on line 4 of the code.

    • authtoken = "copy and paste your authtoken here"to something like, authtoken = "67xxxxxxxxxxxxxxxxx".

  • You can change the carrier name/shipping medium by making changes to line 38 of the code that says: ship.put("delivery_method","dhl"); //REPLACE WITH SHIPPING CARRIER NAME - for e.g., "dhl" can be replaced with "fedex" or something of your choice like say, "delivery_by_self" or "picked_up_by_customer".

  • Note: If you have enabled auto-generation of package numbers for your organization, then you don't need these two lines:

    • //package_number = salesorder.get("salesorder_number").replaceFirst("SO","PA");

    • //mapper.put("package_number",package_number);

  • Once everything is ready, hit Save.


Henceforth, all your offline sales orders (that have been confirmed) will have packages and manual shipment records created inside of Zoho Inventory.

Please check out the part 2 of this post titled - Tip #4.2 Auto-creating package and shipment records for your online sales orders on our forums.

Until next time.

Your everyday end user,
Ajay Aadhithya Chandrasekaran
Zoho Inventory


    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now