Support: 8055013343 support@innoventry.in
Sales: 8055013343 sales@innoventry.in

How to use scripting for attributes

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 NameField TypePurpose
Profile LengthNumericLength value of profile
External PerimeterNumericOuter perimeter value
Qty In PcsNumericNumber of pieces for calculation
Coating PerimeterNumericAuto 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:

  1. Edit the item.
  2. Go to the Trade Attributes tab.
  3. Select the “Coating Calculation” group.
  4. 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:

  1. Select the item with “Coating Calculation” group attached.
  2. Enter values for:
    • Profile Length
    • External Perimeter
    • Qty In Pcs
  3. 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.

Powered by BetterDocs