Solved

Is it possible to edit the template item ID on a stock item

  • 3 March 2021
  • 3 replies
  • 281 views

Userlevel 3
Badge

Is there an option that would allow a stock item to be added to or removed from an existing template ID?  

Example, an existing item is purchased from the manufacturer today with only one size and one color.  However, the following year they update the product to include multiple sizes and color.  We want to retain the history with the original size and color, but then add that item to a template item which includes the additional sizes and colors. I thought there was an option/configuration to allow the editing of template ID on an item, but can’t seem to find it.  Anyone know if that functionality exists?

icon

Best answer by davidnavasardyan09 22 August 2023, 01:27

View original

3 replies

Userlevel 3
Badge

I’m curious about this too. Doesn’t seem possible. 

Userlevel 5
Badge +1

Hi @di93 There isn't a built-in way in Acumatica to dynamically add or remove items from a Template ID after it's been created. However, you can achieve this using a custom process or customization. For example
in the Stock Items screen (IN202500), create a new template item that includes all the attributes (sizes and colors) needed. Let's assume you create a template item with Template ID 'T1'. Add a new action to the InventoryItemMaint graph extension. This action will update the template ID of an existing item and create new stock items based on the new template.

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint>
{
public PXAction<InventoryItem> UpdateTemplate;
[PXButton]
[PXUIField(DisplayName = "Update Template", Enabled = true, MapEnableRights = PXCacheRights.Update)]
protected virtual void updateTemplate()
{
InventoryItem item = Base.Item.Current;

if (item == null)
return;

// Update the template ID of the existing item
item.TemplateItemID = "T1"; // New template ID
Base.Item.Update(item);

// Create new stock items based on the new template
foreach (var size in new[] { "S", "M", "L" })
{
foreach (var color in new[] { "Red", "Blue", "Green" })
{
InventoryItem newItem = new InventoryItem();
newItem.InventoryCD = $"{item.InventoryCD}_{size}_{color}";
newItem.Descr = $"{item.Descr} - {size} - {color}";
newItem.TemplateItemID = "T1";
newItem = Base.Item.Insert(newItem);

// Add attribute values
PXCache attributesCache = Base.Caches[typeof(CSAnswers)];
CSAnswers sizeAttribute = new CSAnswers();
sizeAttribute.AttributeID = "SIZE";
sizeAttribute.Value = size;
attributesCache.Insert(sizeAttribute);

CSAnswers colorAttribute = new CSAnswers();
colorAttribute.AttributeID = "COLOR";
colorAttribute.Value = color;
attributesCache.Insert(colorAttribute);
}
}

// Save changes
Base.Actions.PressSave();
}
}

Note that this example does not handle data migration or inventory adjustments. You may need to adjust transactions, like sales orders and purchase orders, that were previously linked to the old stock item. You can do this using the Data Import functionality or by running a SQL script to update the references in the database.

Userlevel 3
Badge

It is absolutely possible, we do it all day long. Read this article:

 

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved