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 :
Finance | Project Operations, Human Resources, ...
Answered

Product creation and release using dataentity

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am trying to use below code for product create and relase, but there are few fields in EcoResReleasedProductEntity in which i need to update data. I am not able to figure out how i can access EcoResReleasedProductEntity using below code? Also if there is any other way to achieve this please suggest. Thanks!

EcoResProductEntity                        ecoResProductEntity;

EcoResProductEntityToCrossTableDataAdaptor adaptor;
EcoResProduct                              product;

NumberSequenceReference                    numberSequenceReference = EcoResProductParameters::numRefProductNumber();
NumberSequenceTable                        numberSequenceTable = numberSequenceReference.numberSequenceTable();

Args                                       args;

NumberSeq                                  numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId);

EcoResProductReleaseSessionManager         productReleaseSessionManager;
EcoResReleaseSessionRecId                  releaseSessionRecId;

CompanyInfo                                companyInfo = CompanyInfo::find();


ecoResProductEntity.ProductNumber                   = numberSeq.num();
ecoResProductEntity.ProductSearchName               = "myItem";
ecoResProductEntity.ProductName                     = "My Item";
ecoResProductEntity.ProductType                     = EcoResProductType::Item;
ecoResProductEntity.ProductSubType                  = EcoResProductSubtype::ProductMaster;
ecoResProductEntity.VariantConfigurationTechnology  = EcoResVariantConfigurationTechnologyType::PredefinedVariants;
ecoResProductEntity.ProductDimensionGroupName       = "Prod_Dim";

// here you can set all the fields of the data entity that you need

adaptor = EcoResProductEntityToCrossTableDataAdaptor::newFromEntity(ecoResProductEntity);

ttsbegin;

product = EcoResProductCrossTableManager::makeProductRecord(adaptor);

EcoResProductCrossTableManager::insert(adaptor, product);
// here you can create one or more translations
EcoResProductTranslation::createOrUpdateTranslation(product.RecId, "it translation", '', "it");

// now we want to release that master product for the current company    
productReleaseSessionManager    = EcoResProductReleaseSessionManager::newReleaseSession();
releaseSessionRecId             = productReleaseSessionManager.parmReleaseSessionRecId();

productReleaseSessionManager.addProduct(product.RecId);
productReleaseSessionManager.addLegalEntityForProduct(companyInfo.RecId, product.RecId);

args = new Args(formStr(EcoResProductRelease));
args.record(EcoResReleaseSession::find(releaseSessionRecId));

// the first boolean parameter is for showing a log for errors
// the second boolean parameter is for executing the release with a batch          
if (EcoResProductReleaseSessionBatch::runJob(args, true, false))
{
    productReleaseSessionManager.cleanUp();
}

ttscommit;
I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi Lalit,

    Please have a look at this thread, use EcoResProductEntity and EcoResProductEntityToCrossTableDataAdaptor to create product:

    stackoverflow.com/.../ax-365-create-product-with-x-code

    Hope this helps.

  • Community Member Profile Picture
    on at

    Hi WIll,

    Its the same code I am using above, my problem is i want to access entity EcoResReleasedProductEntity while releasing product to update some fields.

    Thanks!

  • udaY-ch Profile Picture
    5,133 on at

    Hi

    Exactly what you want to update or set in EcoResReleasedProductEntity? Did you try using EcoResProductReleaseManager class to set values  for invent related tables! only to release the item

    Uday

  • Verified answer
    Rahul Mohta Profile Picture
    21,032 on at

    why to use code when u can use 2 data entities Products v2 and Released products v2

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans