web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX2012 create product by code and release

(0) ShareShare
ReportReport
Posted on by 200

Hello I have a problem. I like to create a Product by sourcecode.

When I try to release these Products I get the following error:

Field 'ItemId' must be filled in.

 

Here my code for the creation of a product:

 

 

 

 

 

EcoResDistinctProduct distinctProductTbl;

EcoResProductTranslation productTranslationTbl;

EcoResStorageDimensionGroup storageDimensionTbl;

EcoResStorageDimensionGroupProduct storageDimGroupProduct;

EcoResStorageDimensionGroupItem storageDimGroupItem;

EcoResTrackingDimensionGroup trackingDimensionTbl;

EcoResTrackingDimensionGroupProduct trackingDimGroupProduct;

EcoResTrackingDimensionGroupItem trackingDimGroupItem;

InventTable inventTbl;

InventItem inventItemClass;

 

 

 

str 254

txt1,txt2,txt3;

#file

 

 

 

str

storageDim, storageDimGroupName;

;

distinctProductTbl.initValue();

distinctProductTbl.DisplayProductNumber = _itemId;

distinctProductTbl.ProductType = EcoResProductType::Item;

distinctProductTbl.SearchName = (

 

 

conpeek

(importBuffer,this.importBufferPos(#StockTable_ItemName)));

distinctProductTbl.doInsert();

 

 

 

switch(conpeek

(importBuffer,this.importBufferPos(#StockTable_ItemType)))

{

 

 

 

case '0'

:

{

storageDimensionTbl = EcoResStorageDimensionGroup::findByDimensionGroupName(

 

 

"01"

);

}

 

 

break

;

 

 

 

case '1'

:

{

storageDimensionTbl = EcoResStorageDimensionGroup::findByDimensionGroupName(

 

 

"02"

);

}

 

 

break

;

 

 

 

case '2'

:

{

storageDimensionTbl = EcoResStorageDimensionGroup::findByDimensionGroupName(

 

 

"03"

);

}

 

 

break

;

}

 

productTranslationTbl.initValue();

productTranslationTbl.LanguageId = #StdLanguageId;

productTranslationTbl.Description =

 

 

conpeek

(importBuffer, this.importBufferPos(#StockTable_ItemName2UK));

productTranslationTbl.Name = (

 

conpeek

(importBuffer,this.importBufferPos(#StockTable_ItemName)));

productTranslationTbl.Product = distinctProductTbl.RecId;

productTranslationTbl.insert();

 

 

 

if

(storageDimensionTbl.RecId)

{

 

 

 

if

(distinctProductTbl.RecId)

{

 

 

 

if

(! EcoResStorageDimensionGroupProduct::findByProduct(distinctProductTbl.RecId))

{

storageDimGroupProduct.initValue();

storageDimGroupProduct.Product = distinctProductTbl.RecId;

storageDimGroupProduct.StorageDimensionGroup = storageDimensionTbl.RecId;

storageDimGroupProduct.insert();

}

}

 

 

 

if (! EcoResStorageDimensionGroupItem::findByItem(curext

(), _itemId))

{

storageDimGroupItem.initValue();

storageDimGroupItem.ItemId = _itemId;

storageDimGroupItem.StorageDimensionGroup = storageDimensionTbl.RecId;

storageDimGroupItem.ItemDataAreaId =

 

 

curext

();

storageDimGroupItem.insert();

}

}

trackingDimensionTbl = EcoResTrackingDimensionGroup::findByDimensionGroupName(

 

 

"TD_00"

);

 

 

 

if

(trackingDimensionTbl.RecId)

{

 

 

 

if

(distinctProductTbl.RecId)

{

 

 

 

if

(! EcoResTrackingDimensionGroupProduct::findByProduct(distinctProductTbl.RecId))

{

trackingDimGroupProduct.initValue();

trackingDimGroupProduct.Product = distinctProductTbl.RecId;

trackingDimGroupProduct.TrackingDimensionGroup = trackingDimensionTbl.RecId;

trackingDimGroupProduct.insert();

}

}

 

 

 

if (! EcoResTrackingDimensionGroupItem::findByItem(curext

(), _itemId))

{

trackingDimGroupItem.initValue();

trackingDimGroupItem.ItemId = _itemId;

trackingDimGroupItem.TrackingDimensionGroup = trackingDimensionTbl.RecId;

trackingDimGroupItem.ItemDataAreaId =

 

 

curext

();

trackingDimGroupItem.insert();

}

}

 

 

this.releaseProductToCurrentLegalEntity(_itemId);

 

 

 

 

return

distinctProductTbl;

 

 

*This post is locked for comments

I have the same question (0)
  • Ajit Profile Picture
    8,755 on at

    Hi Christian -

    I have written in my blog. Have a look using below link.

    ajit-axaptacomconnector.blogspot.com/.../create-and-release-product-through-code.html

    Thanks,

    Ajit

  • Christian Ramer Profile Picture
    200 on at

    looks quite good, my Items are released and available in the "detailed released products" form but now I do have a problem with my InventDim (I need a standard InventDim with a specified Location and Site assigned.) but the release done by the code creates a new "AllBlank" one and uses this....so the released items do all have the wrong inventdim. When I change the inventdim the items disappear from the released items

    How can this be resolved?

  • Christian Ramer Profile Picture
    200 on at

    sorry....I have to add that the inventitemlocation is set to "AllBlank" and I need my own one "MAST-00001"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans