Tip #4.2 Auto-creating package and shipment records for your online sales orders

Tip #4.2 Auto-creating package and shipment records for your online sales orders

Hello again,


I hope you've checked out the part 1 of this post where we auto-create packages and shipments for your offline orders. This is part 2, and here we will see how we can automatically create packages and manual shipment orders for your online sales orders (or in other words, orders generated from Amazon, Etsy, Ebay or Shopify).

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. Click on the button adjacent to +New Workflow Rule.

  • Select Custom Functions from the drop-down.

  • 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".

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

salesorderID = salesorder.get("salesorder_id");

salesorderdate = salesorder.get("date").toDate();
organizationID = organization.get("organization_id");
//replace the value with your authtoken value
sal = invokeurl
url :"https://inventory.zoho.com/api/v1/salesorders/" + salesorderID + "?authtoken=" + authtoken + "&organization_id=" + organizationID
type :GET
temp = sal.get("salesorder");
// info temp;
new = temp.get("sales_channel");
info new;
mapper = Map();
customerID = salesorder.get("customer_id").toString();
//uncomment the below two lines if you had not enabled auto package number generation
//package_number = salesorder.get("salesorder_number").replaceFirst("SO","PA");
lineItems = salesorder.get("line_items").toList();
newLineItems = List();
for each lineItem in lineItems
lineItemMap = Map();
solineitemID = lineItem.get("line_item_id");
quantity = lineItem.get("quanity");
jsonString = Map();
info jsonString;
response = invokeurl
url :"https://inventory.zoho.com/api/v1/packages?authtoken=" + authtoken + "&salesorder_id=" + salesorderID + "&organization_id=" + organizationID
type :POST
info mapper;
info response.toMap().get("message");
ship.put("delivery_method","dhl"); //REPLACE WITH YOUR SHIPPING CARRIER NAME
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");
info "SO from direct sales";
  • Copy and replace your authtoken number inside the code.

  • You can change the carrier name/shipping medium by making changes to this line: ship.put("delivery_method","dhl"); //REPLACE WITH SHIPPING CARRIER NAME.

  • 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, whenever an online sales order gets generated within Zoho Inventory, a package and a manual shipment record will be created for it.

Until next time.

Your everyday end user,
Ajay Aadhithya Chandrasekaran
Zoho Inventory

    Zoho Pagesense Resources

        Zoho SalesIQ Resources

              Zoho TeamInbox Resources

                Zoho DataPrep Resources

                    Zoho CRM Plus Resources

                      Zoho Books Resources

                        Zoho Subscriptions Resources

                          Zoho Desk Resources

                            Zoho Projects Resources

                              Zoho Sprints Resources

                                Qntrl Resources

                                  Zoho Creator Resources

                                    Zoho WorkDrive Resources

                                        Zoho Campaigns Resources

                                          Zoho CRM Resources

                                                      Design. Discuss. Deliver.

                                                      Create visually engaging stories with Zoho Show.

                                                      Get Started Now