How can I update the InventDim table - Axapta

This is a discussion on How can I update the InventDim table - Axapta ; Hello, I got this error when I tried the following code. Any ideas? Error: Cannot create a record in Inventory dimensions (InventDim). Dimension No.: AllBlank. The record already exists. InventDim.clear(); InventDim = InventDim::findOrCreate(inventDim); InventDim.InventLocationId = sLocationId; InventDim.configId = sConfigId; InventDim.InventColorId ...

+ Reply to Thread
Results 1 to 3 of 3

How can I update the InventDim table

  1. Default How can I update the InventDim table

    Hello, I got this error when I tried the following code. Any ideas?

    Error:
    Cannot create a record in Inventory dimensions (InventDim). Dimension No.:
    AllBlank.
    The record already exists.

    InventDim.clear();
    InventDim = InventDim::findOrCreate(inventDim);
    InventDim.InventLocationId = sLocationId;
    InventDim.configId = sConfigId;
    InventDim.InventColorId = sColorId;
    InventDim.inventBatchId = sBatchId;
    InventDim.wMSLocationId = sWMSLocId;
    InventDim.wMSPalletId = sWMSPalletId;
    InventDim.inventSerialId = sSerialId;
    InventDim.afcInventContainerId = sContainerID;
    InventDim.insert(true);
    InventDim.update();


  2. Default RE: How can I update the InventDim table

    Hi,

    Try the find method (not the findOrCreate).

    {
    InventDim id;
    InventDimID idd;
    ;

    id.clear();

    id = InventDim::find(idd, true);

    id.insert();

    id.update();
    }

    "new2ax" wrote:

    > Hello, I got this error when I tried the following code. Any ideas?
    >
    > Error:
    > Cannot create a record in Inventory dimensions (InventDim). Dimension No.:
    > AllBlank.
    > The record already exists.
    >
    > InventDim.clear();
    > InventDim = InventDim::findOrCreate(inventDim);
    > InventDim.InventLocationId = sLocationId;
    > InventDim.configId = sConfigId;
    > InventDim.InventColorId = sColorId;
    > InventDim.inventBatchId = sBatchId;
    > InventDim.wMSLocationId = sWMSLocId;
    > InventDim.wMSPalletId = sWMSPalletId;
    > InventDim.inventSerialId = sSerialId;
    > InventDim.afcInventContainerId = sContainerID;
    > InventDim.insert(true);
    > InventDim.update();
    >


  3. Default RE: How can I update the InventDim table

    Hi,

    two things...

    1.
    you are calling .insert(true) and you have not set a inventDimId for your
    record.
    So, by default, the inventDimId is "AllBlank" and this record exists in
    every Dynamics AX system (created automatically).

    2.
    It is (normaly) not a good idea to update an existing inventDim record,
    because the table InventDim holds every combination of inventory dimensions
    used in you system. So have have refernces to the inventDim record
    (Inventory-Transactions, Sales orders, purchase orders, and so on).
    It is a better way to use the findOrCreate method to look if the record
    exists and when not, to create it.

    Sample:

    InventDim.clear();

    InventDim.InventLocationId = sLocationId;
    InventDim.configId = sConfigId;
    InventDim.InventColorId = sColorId;
    InventDim.inventBatchId = sBatchId;
    InventDim.wMSLocationId = sWMSLocId;
    InventDim.wMSPalletId = sWMSPalletId;
    InventDim.inventSerialId = sSerialId;
    InventDim.afcInventContainerId = sContainerID;

    InventDim = InventDim::findOrCreate(inventDim);


    --
    Sincerely yours
    Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)


    "new2ax" wrote:

    > Hello, I got this error when I tried the following code. Any ideas?
    >
    > Error:
    > Cannot create a record in Inventory dimensions (InventDim). Dimension No.:
    > AllBlank.
    > The record already exists.
    >
    > InventDim.clear();
    > InventDim = InventDim::findOrCreate(inventDim);
    > InventDim.InventLocationId = sLocationId;
    > InventDim.configId = sConfigId;
    > InventDim.InventColorId = sColorId;
    > InventDim.inventBatchId = sBatchId;
    > InventDim.wMSLocationId = sWMSLocId;
    > InventDim.wMSPalletId = sWMSPalletId;
    > InventDim.inventSerialId = sSerialId;
    > InventDim.afcInventContainerId = sContainerID;
    > InventDim.insert(true);
    > InventDim.update();
    >


+ Reply to Thread