> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/utilities/import-masters-transactions-from-external-files/import-purchase-vouchers-from-external-file/import-purchase-vouchers-configuration/auto-generate-user-codes.md).

# Auto Generate User Codes

**YouTube:** [How to Auto-Generate Item User Codes in Import PUV Configuration?](https://youtu.be/SmJ2YWreF90)

## How to Auto-Generate Item User Codes in Import PUV Configuration?

In this tutorial, we will learn how to use the **"Auto Generate User Codes"** option while importing a Purchase Voucher from an external file in Logic ERP.

This feature allows the system to automatically generate a **User Code or Item Code** when the corresponding code is not defined in the imported Excel file.

***

### Access to the Import Configuration

To access the required option:

* Navigate to **Import Purchase Vouchers from External File**.
* Open the **Configuration** window.
* Locate the option labeled as

> **"Auto Generate User Codes"**

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F037VBdg2Jo33VEaChN0J%2FCNF.png?alt=media&amp;token=58d8a248-3e02-4030-b19e-d117dd34fb9c" alt=""><figcaption></figcaption></figure>

Before enabling this option, let's first understand the default behavior.

***

### Import the File with User Code Disabled

Let's first import the Purchase Excel file without defining the **User Code or Item Code**.

* Keep **"Auto Generate User Codes"** disabled.
* Import the required Purchase Excel file.

**System Behavior**

* As you can see, in the **Header Details** section, the **Invalid Doc** column displays **Yes**, indicating that the document contains invalid items.
* To identify the invalid items:
  * Open the **Invalid Item Details** tab under the **Item Details** section.

As you can see, all the items have been identified as invalid.

The **Invalid Remarks** column displays the reason:

> **"Item Code Can't Be Blank"**

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FwCUemKBnOoVHv0q7dbZ3%2FInvalid.png?alt=media&amp;token=6e759621-1316-4889-a560-a633b26f6252" alt=""><figcaption></figcaption></figure>

This indicates that the system requires an Item Code for the imported items.

***

### Let's Enable Auto Generate User Codes

If the Item Code is not available in the Excel file, you can configure the system to automatically generate a User Code.

To enable this feature:

* Return to the **Configuration** window.
* Enable **"Auto Generate User Codes"**.
* Define the required **User Code Prefix**.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FfxmUv5hqdMUlNeP0cYEm%2FUser%20Code%20Prefix.png?alt=media&amp;token=7f348b6c-dece-4044-a88a-654b3d98e77a" alt=""><figcaption></figcaption></figure>

* Save the configuration changes.

***

### Import the Purchase File Again

Now, let's import the same Purchase Excel file again.

#### System Behavior

As you can see, the **Invalid Doc** column now displays **No**, indicating that there are no invalid items and the file is ready for import.

The system has automatically generated the required User Codes based on the configured prefix.

* Proceed with importing the Purchase document.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FCfkzAg8mkdAPXqvuVDbT%2FPurchase%20Import.png?alt=media&amp;token=56a5612a-bcbe-447a-84a8-23c86f8a5860" alt=""><figcaption></figcaption></figure>

#### Import Result

The document has been successfully imported.

***

### Verify the Imported Purchase Voucher

Let's verify the result in the **Purchase Voucher** module.

* Open the imported Purchase Voucher.
* Review the purchase item details.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2Ff7CSP1mDjYNFk4f8dxgq%2FItem%20Code.png?alt=media&amp;token=8e1e5738-5dc8-44a3-9811-ce6d279cc742" alt=""><figcaption></figcaption></figure>

As you can see, the purchase details have been successfully reflected in the Purchase Voucher along with the **automatically generated User Code or Item Code**.

***

### Final Outcome

By enabling **"Auto Generate User Codes"** and defining a **User Code Prefix**, Logic ERP can automatically generate the required User Code or Item Code when it is not provided in the external purchase file. This helps prevent item-code-related import errors and allows the purchase document to be imported successfully.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/utilities/import-masters-transactions-from-external-files/import-purchase-vouchers-from-external-file/import-purchase-vouchers-configuration/auto-generate-user-codes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
