jueves, 17 de mayo de 2012

Item type change from Item to Service

We've generated an error changing an item type to that of a Service.

In English:
Item type cannot be changed to %1 because inventory value has been posted for the item.
First set inventory value to 0.
In Spanish:
No se puede cambiar el tipo de artículo a %1, ya que el valor del inventario se ha registrado para el artículo.
Primero fijar el valor del inventario en 0.

Navigating to the item form (InventTable) and searching for the item we can see that the Availability of the item is not set to zero, we have some in stock.  We found a suggestion that we should therefore close off the inventory (MSDN), although manually updating the available quantity to zero (Inventory management > Forms > Item details > Available > Adjust Quantitywould work if there was no asociated inventory value in the purchase or sales order line for example...  Instead of closing the inventory I opted to adjust the posted value in the transactions to zero (Inventory management > Periodic > Closing and adjustment > Adjust > Transactions). 


In code use the InventItemTypeChange class to update item types, although in the job below I changed the visibility on the buildConfirmTxt static method to public...  For brevity and changes applied by the Eastern Europe/Russia GLS layer (GEEU tags in the code).
static void Job1(Args _args)
{
    InventItemTypeChange    iitc;
    container               confirmTxt;
    ItemType                itemType = ItemType::Service;
    ItemId                  itemId   = "YourItemId";
    #define.posCanChangeType(1)
    ;

    confirmTxt = InventItemTypeChange::buildConfirmTxt(itemId, itemType);
    if (conpeek(confirmTxt, #posCanChangeType) == true)
    {
        iitc        = new InventItemTypeChange();
        iitc.parmItemId(itemId);
        iitc.parmItemType(itemType);
        iitc.run();
    }
}

No hay comentarios:

Publicar un comentario