Generating Item Codes Using Custom Logic

Generating Item Codes Using Custom Logic

Overview

This article will guide you through the process of setting up custom logic for generating item codes in iVendNext, along with practical examples and best practices.




Why Use Custom Logic for Item Codes?

Item codes are used to identify and manage inventory efficiently. While you can manually assign item codes, using custom logic to generate them automatically can save time, reduce errors, and ensure consistency across your inventory. Custom logic allows you to generate item codes based on specific attributes, such as item group, brand, or material. Here are some benefits of using custom logic:


Consistency

Ensures that all item codes follow a standardized format.


Efficiency

Automates the process, saving time and reducing manual effort.


Scalability

Easily handles a growing inventory without requiring additional manual input.


Error Reduction

Minimizes the risk of duplicate or incorrect item codes.




Step-by-Step Guide to Setting Up Custom Logic

1. Understand the Requirements

Before setting up custom logic, determine the structure of your item codes. For example, you might want the first two characters to represent the item group, the next two to represent the brand, and the remaining characters to be sequential numbers.


Example Structure:

  • TA (Test A) + BA (Brand A) + 001 (Sequential Number) = TABA001


2. Add Custom Script to the Item Master

In iVendNext, you can add a custom script to the Item master to generate item codes automatically. Here’s how to do it:


  1. Access the Script Editor:


  • Go to the Item master in iVendNext.

  • Navigate to the Custom Script section.


  1. Add the Custom Script:


  • Use the following script as a template to generate item codes based on item group and brand:


cur_frm.cscript.custom_validate = function(doc) {

    // Clear the item_code field

    doc.item_code = "";


    // First 2 characters based on item_group

    switch(doc.item_group) {

        case "Test A":

            doc.item_code = "TA";

            break;

        case "Test B":

            doc.item_code = "TB";

            break;

        default:

            doc.item_code = "XX";

    }


    // Add next 2 characters based on brand

    switch(doc.brand) {

        case "Brand A":

            doc.item_code += "BA";

            break;

        case "Brand B":

            doc.item_code += "BB";

            break;

        default:

            doc.item_code += "BX";

    }


    // Add sequential numbers (optional)

    // You can use a database query or counter to generate sequential numbers

    doc.item_code += "001"; // Replace with dynamic logic for sequential numbers

}


3. Test the Script

  • Create a new item in the Item master and select an item group and brand.

  • The item code should be automatically generated based on the custom logic you defined.




Examples of Custom Logic

Example 1: Item Group + Brand

  • Item Group: Fashion and Clothing → FC

  • Brand: Old Navy → ON

  • Generated Code: FCON-001


Example 2: Material + Type + Size

  • Material: Cotton → C

  • Type: Formal → F

  • Size: 30 cm → 30

  • Generated Code: CF-30


Example 3: Category + Subcategory + Sequential Number

  • Category: Men → M

  • Subcategory: Shirt → S

  • Sequential Number: 001

  • Generated Code: MS-001




Best Practices for Using Custom Logic

Some of the best practices are:


1. Keep It Simple

Avoid overly complex logic that may be difficult to maintain or understand. Stick to a structure that is easy for your team to follow.


2. Use Meaningful Codes

Ensure that each part of the code represents a specific attribute of the item. This makes it easier to identify items at a glance.


3. Test Thoroughly

Before implementing custom logic in a live environment, test it extensively to ensure it works as expected and doesn’t generate duplicate or incorrect codes.


4. Document the Logic

Maintain a document that explains the custom logic used for generating item codes. This will help new team members understand the system and make future updates easier.


5. Plan for Scalability

As your business grows, your item code structure may need to evolve. Ensure that your custom logic can accommodate future changes, such as adding new item groups or brands.




Advanced Customization

For more advanced users, you can extend the custom logic to include additional attributes, such as:


Sequential Numbers

Use a database query to generate unique sequential numbers for each item.


Date-Based Codes

Include the year or month in the item code for better tracking.


Supplier Codes

Incorporate supplier-specific codes for easier cross-referencing.




    • Related Articles

    • Managing Supplier Item Codes

      Overview This article will guide you through the steps to manage supplier item codes effectively, ensuring smooth purchase transactions and better supplier collaboration. Why Track Supplier Item Codes? In a retail business environment you deal with ...
    • Creating Custom Reports Using Report Builder

      Overview Report Builder in iVendNext lets you create custom reports easily—no technical skills needed. From sales summaries to inventory updates, it helps you pull and format data quickly. This article guides you through building a report, choosing ...
    • Item Codification

      Overview This article will guide you through the importance of item codification, its benefits, challenges, and best practices for implementing it in your retail business. What is Item Codification? Item codification refers to the process of ...
    • Linking UoM with UPC Codes for Accurate Inventory Management

      Overview In retail, Units of Measure (UOM) and Universal Product Codes (UPC) work together to ensure accurate tracking and management of items. While UOMs define how an item is measured (e.g., by weight, volume, or quantity), UPCs uniquely identify ...
    • Using Web Forms for Feedback Collection

      Overview This article guides you through setting up, customizing, and automating feedback collection using Web Forms. 1. Why Use Web Forms for Feedback? Benefits of Feedback Web Forms ✅ Structured Data – Standardized ratings and comments for easy ...