How to Use Scripting Language for Attribute-Based Calculations #
This document explains how to set up attributes, write a script to automatically calculate coating perimeter, and use it in sale transactions in Innoventry software.
Prerequisite #
Ensure that you already have access to the Attribute setup and scripting features in your Innoventry installation.
Step 1: Create Attribute Group #
Go to Master → Attribute Group and create a new attribute group:
- Group Name: Coating Calculation
- Attribute Type: Trade Attribute Group
- Attach To: Item
Click Save to create the group. This group will now be used to store related attributes that control the coating calculation logic in transactions.
Step 2: Add Required Attributes #
Inside the “Coating Calculation” group, create these attributes:
| Attribute Name | Field Type | Purpose |
|---|---|---|
| Profile Length | Numeric | Length value of profile |
| External Perimeter | Numeric | Outer perimeter value |
| Qty In Pcs | Numeric | Number of pieces for calculation |
| Coating Perimeter | Numeric | Auto calculated result |
The first three will be entered by the user for each item, and “Coating Perimeter” will be calculated by script.
Step 3: Add Script to Code Script Attribute #
Open the Code Script window for one of the attributes (e.g., in “Profile Length” code script panel).
Paste the following scripting logic:
attrs.setValue( "Coating Perimeter",
attrs.getValue("Profile Length") *
attrs.getValue("External Perimeter") *
attrs.getValue("Qty In Pcs") *
0.8 *
0.00155
);
invtx.setQty(attrs.getValue("Coating Perimeter"));
attrs.disable("Coating Perimeter");
invtx.disableQty();
Script Description #
- attrs.getValue(“X”): fetches the user-entered value of an attribute
- attrs.setValue(“Coating Perimeter”, …): calculates and writes the result
- 0.8: example factor (e.g., efficiency multiplier)
- 0.00155: conversion factor (depends on unit logic)
- invtx.setQty(): sets the sale transaction quantity automatically
- attrs.disable() / invtx.disableQty(): prevents manual change of calculated fields
Step 4: Attach the Attribute Group to an Item #
Open the Item Master for any item and attach the newly created attribute group:
- Edit the item.
- Go to the Trade Attributes tab.
- Select the “Coating Calculation” group.
- Save the item.
After this, when you enter the item in a sale transaction, the attributes will appear for user input where needed.
Step 5: Using in Sale Transaction #
In sale invoice:
- Select the item with “Coating Calculation” group attached.
- Enter values for:
- Profile Length
- External Perimeter
- Qty In Pcs
- The system will automatically calculate Coating Perimeter and set the quantity based on the formula.
The transaction will now hold the calculated values and correct pricing or billing metrics without needing the user to compute manually.
Helpful Links #
For general custom field addition in sale transactions, see:
How to Add Custom Field of Item in Sale Transaction
:contentReference[oaicite:1]{index=1}Troubleshooting and Notes #
- Ensure attribute names in the script exactly match the attribute names created in the system.
- Verify numeric units and factors are correct for your business logic before final deployment.
- If you do not see the attribute group in sale transaction, revisit the item setup and ensure the attribute group is attached.