在AX 2012中,我们通过使用某些类来轻松创建产品和产品主数据,如:
window.captureEvents (Event.UNLOAD)
window.onunload = page_click;
function page_click() {
alert('page unload event detected!');
}
AX 365中不存在这些类。我需要通过编码创建已发布的产品。如果您知道如何创建,请分享。提前谢谢。
答案 0 :(得分:2)
我想使用AX 2012可以更容易地使用X ++代码创建和发布产品,但是如果您愿意,可以使用AX7(或者动态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;
我希望它可以帮到你
答案 1 :(得分:0)
感谢Il Vic这个解决方案非常适合创建已发布的产品。我先试过这个,但发现" EcoResProductEntityToCrossTableDataAdaptor"已经实现了一个接口" EcoResIProductCrossTableData"。如果我们通过实现" EcoResProductEntityToCrossTableDataAdaptor"类,我们发现不允许调用许多重要的parm方法。实现该方法以抛出错误。所以只有一个选择左,实现界面" EcoResIProductCrossTableData"你自己。我做了,工作就像一个魅力。