gpt4 book ai didi

axapta - AX 365 使用 x++ 代码创建产品

转载 作者:行者123 更新时间:2023-12-05 04:11:08 35 4
gpt4 key购买 nike

在 AX 2012 中,我们过去常常通过使用一些类进行编码来轻松创建产品和产品母版,例如:

 ecoresProductService  = EcoResProductService::construct();
ecoResEcoResProduct = new EcoResEcoResProduct();
distintMaster = new EcoResEcoResProduct_Product_Distinct();

这些类在 AX 365 中不存在。我需要通过编码创建已发布的产品。如果您知道如何创建,请分享。提前致谢。

最佳答案

我猜想使用 AX 2012 可以更容易地使用 X++ 代码创建和发布产品,但是使用 AX7(如果您愿意,也可以使用 dynamics 365)可以获得相同的结果。

想法是使用产品数据实体(即EcoResProductEntity)和一些标准的——长命名的——类。

代码如下:

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;

希望对你有帮助

关于axapta - AX 365 使用 x++ 代码创建产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43338160/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com