Tip #2.1 Auto-updating shipment charges from multiple shipment records to sales orders in Zoho Inventory

Tip #2.1 Auto-updating shipment charges from multiple shipment records to sales orders in Zoho Inventory

Hello,

Hope you are doing good today.


Last week we saw how  we could convert our online sales orders into invoices automatically . This week, we will see how we can automate the process of adding up shipment charges from across multiple shipment orders and add the total shipment cost to a sales order or an invoice using custom functions. To make it easy on the reader, we have split this post into two parts. Part 1, or in other words this post will tell you how to apply this custom function to sales order. The subsequent post will tell you how you can do the same for your invoices.

How does this work?
Let's suppose you have a sales order containing 10 different items of varying quantities and availability. For some reason, you are unable to ship all of them together and so you ship them in 3 parts. Now, you have 3 shipment orders incurring different shipment charges. Normally, you'll have to obtain and add the shipment charges manually and then input the total number at the time of invoicing a customer.   

This can be quite tiresome. However, you can automate this using a custom function that captures shipment charges from every shipment associated with a particular sales order, adds them to arrive at a total shipment charge and updates this total to either your sales order or your invoice. 

Cool, are there any pre-requisites?
1) This automation will work only for manual shipments.
2) To update the total shipment charge to sales orders, all the items have to be shipped. 
3) You'll need to generate an auth token for your account. To do so, log in to your Zoho Account and then  click on this link before you begin setting up this custom function . Copy the auth token and keep it safe.

Alright, how do I set this up?

Method 1. Auto-updating total shipment charge to a sales order:

  • Open your Zoho Inventory.

  • Click on the Gear icon from the top-right corner, and select Automation from the drop-down.

  • Inside the Automation page, click on the drop-down button adjacent to +New Workflow button to select Custom Functions from the drop-down.

  • Give your workflow a name without any spaces between words.

  • Set Module as Sales Orders. 

  • Set the condition as: "When a Sales Order is created or edited".

  • Execute the Workflow "when any field is updated". and choose "Everytime".

  • Click on the advanced filter and set the condition as: "When Shipment Status is Shipped".

  • Finally, you are required to set the trigger point for this function as "Immediate".

  • Copy and paste the code segment below into the Deluge pane:

authtoken = "Copy and paste your auth token here"; 

shipamt = List();

salesorderID = salesorder.get("salesorder_id");

refnum = salesorder.get("reference_number");

info refnum;

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

organizationID = organization.get("organization_id");

//replace authtoken and orgid

response = invokeurl

[

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

type :GET

];

so = response.get("salesorder");

pkg = so.get("packages").toList();

sid = List();

for each pk in pkg

{

sid.add(pk.get("shipment_id"));

}

i = 0;

sumamt = 0;

for each index i in sid

{

resp = invokeurl

[

url :"https://inventory.zoho.com/api/v1/shipmentorders/" + sid.get(i) + "?authtoken=" + authtoken + "&organization_id=" + organizationID

type :GET

];

shipdet = resp.get("shipmentorder");

charges = shipdet.get("shipping_charge").toDecimal();

sumamt = sumamt + charges;

}

info sumamt;

bson = Map();

bson.put("salesorder_number",salesorder.get("salesorder_number"));

bson.put("customer_id",salesorder.get("customer_id"));

bson.put("shipping_charge",sumamt);

fin = zoho.inventory.updateRecord("SalesOrders",organizationID,salesorderID,bson);

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

  • Make sure you copy and paste the auth token number that you had generated earlier to line 1 of this code fragment that says: authtoken = "Copy and paste your auth token here";

  • Hit Save to finish.

Now every time you have a Sales Order in Shipped status, the total shipment charge will be calculated and added to the sales order automatically. If you have any questions, email them to support@zoho-inventory.com

Please check out the part 2 of this post titled " Tip #2.2 Auto-updating shipment charges from multiple shipment records to invoices in Zoho Inventory" in our forums. Thanks!

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