Tip #9 Invoice level weight calculation

Tip #9 Invoice level weight calculation

Greetings to all ! 

We are glad to inform you that using this custom function you can meet the scenario where in you have to calculate the total weight of all the items in the invoice taking into account the individual item weights.

Prerequisite:
1. Create 2 custom fields in the item module :
Settings > Preferences > Items  > Field Customization > New Custom Field ( Decimal datatype )

1. Weight Per Item ( API Field Name: cf_weight_per_item, Decimal datatype) - Weight of the Item - To be filled during Item creation.
2. Overall Weight( API Field Name: cf_overall_weight, Decimal datatype ) - Script will calculate and update the line item weight. ( Weight per item * quantity)

2. Create 1 custom field in the invoice module:
Settings > Preferences > Invoices > Field Customization > New Custom Field 
1. Total Weight   ( API Field Name: cf_total, Decimal datatype) To calculate and update the Total weight in Invoice.

3. Create Custom function
Navigate and flow the below steps for the same.
      Settings > Automations > Custom Functions > New Custom Function.
      Module: Invoice
     Copy and paste the Weight Calculation Script from this link.
     Create connection for Zoho Inventory - zilink   
            Steps to create connection: 
Click on the "Connections" button above the Deluge script section on the top right side.
It will open up Connections Section. Click on "+Add connection".
Scroll down Pick Your Service section and click on Zoho Inventory.
Provide the Connection Name as zilink and Give Connection Link name as zilink as well.
Also Uncheck the box "Use credentials of Login User".
Under Scopes select ZohoInventory.FullAccess.all
Click Create and Connect, it redirects to a pop up window. Click on Proceed.
Click Accept in the next window and Connection created successfully message will be shown.
4. Create workflow

Settings > Automations > Workflow Rules > New Workflow Rule

Module : Invoice
Workflow Type : Event Based
When an Invoice is: Created/Edited
Execute the workflow when : When any field is updated
Filter the triggers : (You can skip)

Choose the appropriate custom function in the Action.
Save the workflow. ( Please find the attached screenshot for reference. )

On each invoice creation workflow automatically calculates the line item level weight and total weight of Items in an Invoice.

CUSTOM FUNCTION SCRIPT - LINK