Validation on HSN Code

By | October 28, 2021

In Sage X3, we do have Indian Legislation addon module developed which is suitable for Indian business. Good and Service tax is part of the Indian Legislation where defining HSN code against product and service is mandatory. HSN stands for “Harmonized System of Nomenclature”. HSN code is a 6-digit uniform code that classifies 5000+ products and is accepted worldwide. In India, HSN code has extra 2 digits for further classification. The main purpose of HSN is to classify goods from all over the World in a systematic and logical manner. This brings in a uniform classification of goods and facilitates international trade.

There was a requirement from one of the client to add validation on HSN master where HSN number will take minimum 7 digits for creation not less than that. For example, if the user is trying to enter the HSN code less than 7 digit then it will give a popup message as “HSN code should be greater than 6 digit” and it won’t allow to create HSN Code till user enters the HSN Code greater than or equal to 7. Also client had requested us to add same validation on the Sales Invoice screen while selecting HSN Code in the detail line where the length of HSN code should not be less than 7 digits.

To achieve the above requirement follow the below steps:

Step 1: Go to Development ->Script Dictionary ->Windows and open HSN master window(XX1P4HSN)

Step 2: Jump to ‘XX1P4HSNMST’ screen and add ‘After field’ & ‘After change’ actions on HSNCODE field as per below screenshot :

New Stuff : Restriction on Sales Order if date exceeds the defined due date

[HSN Master screen]
[HSN Master screen]

Step 3: Save and validate the screen and global validate the window

Step 4: Add the below code in SPEHSN script :


Add the similar code in AP_XX1P4HSNCODE action and compile the script.

Now if the user tries to enter less than 7 digits in HSN code field then it will give a popup as “HSN code should be greater than 6 digit”.

[HSN master popup]
[HSN master popup]

Similarly, add same validation for the HSN Code in the detail line of the Sales Invoice screen

-Go to OSIH window, jump to SIH4 screen and add ‘After field’ & ‘After change’ action on ‘HSN Code’ field.
-Save and validate the screen and global validate the window.
-Add the below code in AM_XX1P4HSNCODE & AP_XX1P4HSNCODE actions in SPESIH script and compile the script


After applying above validation on sales invoice screen if the user tries to select the HSN code having less than 7 digits from HSN Code finder it will give a popup as below screenshot:

[Sales Invoice- HSN Code popup]
[Sales Invoice- HSN Code popup]

In this way we can add validation on HSN Code field in HSN Master of GST Module and in detail line of Sales Invoice screen.

About Us

Greytrix – a globally recognized and one of the oldest Sage Development Partner is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development and implementation competence. 

Greytrix caters to a wide range of Sage X3, a Sage Business Cloud Solution, offerings. Our unique GUMU™ integrations include Sage X3 for Sage, Dynamics 365 CRM and Magento eCommerce along with Implementation and Technical Support worldwide for Sage X3. Currently we are Sage X3 Implementation Partner in East Africa, Middle East, Australia, Asia, US, UK. We also offer best-in-class Sage X3 customization and development services, integrated applications such as POS | WMS | Payment Gateway | Shipping System | Business Intelligence | eCommerce and have developed add-ons such as Catch – Weight  and Letter of Credit and India Legislation for Sage X3 to Sage business partners, end users and Sage PSG worldwide. Greytrix Sales Commission App for Sage X3 simplifies commission calculations and postings on sales transactions.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

Greytrix is a recognized Sage champion ISV Partner for GUMU™ Sage X3 – Sage CRM integration also listed on Sage Marketplace; GUMU™ integration for Sage X3 – Salesforce is a 5-star rated app listed on Salesforce AppExchange and GUMU™ integration for Dynamics 365 CRM – Sage ERP listed on Microsoft AppSource.

For more information on Sage X3 Integration and Services, please contact us at, We would like to hear from you.