Показать сообщение отдельно
Старый 30.06.2019, 11:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
ievgensaxblog: MSDyn365FO. How-to extend product dimension lookup to add dimension description.
Источник: https://ievgensaxblog.wordpress.com/...n-description/
==============

Recently I saw a question on community forum asking how to extend InventProductDimensionLookup form to add description column, it’s not an obvious task, so I decided to write small blog post about it.

InventProductDimensionLookup form is used to lookup all product dimensions, so we will add new display method to retrieve description from EcoResProductMasterDimValueTranslation table. Simple solution would be to extend form data source, but currently (PU27) there is an issue with display methods. Display method added directly to a form data source accepts current record but display method on extension does not accept anything. Without table buffer display method shows value based on a first record in the grid, that does not make any sense. To workaround this issue we will add new display method to a table extension and check if it is called from a form to grab data required.

[ExtensionOf(tableStr(InventDim))] public final class InventDim_IM_Extension { public display Name displayDimDescription_IM() { FieldId dimFieldId; EcoResProductRecId product; boolean isCalledFromnventProductDimensionLookup; if (FormDataUtil::isFormDataSource(this)) { FormDataSource dataSource = FormDataUtil::getFormDataSource(this); if (formHasMethod(dataSource.formRun(), formMethodStr(InventProductDimensionLookup, inventDimSetupObject))) { Object formRun = dataSource.formRun(); InventDimCtrl_Frm_Lookup inventDimCtrl_Frm_Lookup = formRun.inventDimSetupObject(); dimFieldId = inventDimCtrl_Frm_Lookup.parmMainSortFieldId(); product = InventTable::find(inventDimCtrl_Frm_Lookup.callerItemId()).Product; isCalledFromnventProductDimensionLookup = true; } } Name dimName; if (!isCalledFromnventProductDimensionLookup) { return dimName; } LanguageId userLanguageId = new xInfo().language(); RecId dimRecId; switch (dimFieldId) { case fieldNum(InventDim, configId): EcoResConfiguration ecoResConfiguration; EcoResProductMasterConfiguration ecoResProductMasterConfiguration; select firstonly RecId from ecoResProductMasterConfiguration where ecoResProductMasterConfiguration.ConfigProductMaster == product exists join ecoResConfiguration where ecoResConfiguration.RecId == ecoResProductMasterConfiguration.Configuration && ecoResConfiguration.Name == this.(dimFieldId); dimRecId = ecoResProductMasterConfiguration.RecId; break; case fieldNum(InventDim, inventSizeId): EcoResSize ecoResSize; EcoResProductMasterSize ecoResProductMasterSize; select firstonly RecId from ecoResProductMasterSize where ecoResProductMasterSize.SizeProductMaster == product exists join ecoResSize where ecoResSize.RecId == ecoResProductMasterSize.Size && ecoResSize.Name == this.(dimFieldId); dimRecId = ecoResProductMasterSize.RecId; break; case fieldNum(InventDim, inventColorId): EcoResColor ecoResColor; EcoResProductMasterColor ecoResProductMasterColor; select firstonly RecId from ecoResProductMasterColor where ecoResProductMasterColor.ColorProductMaster == product exists join ecoResColor where ecoResColor.RecId == ecoResProductMasterColor.Color && ecoResColor.Name == this.(dimFieldId); dimRecId = ecoResProductMasterColor.RecId; break; case fieldNum(InventDim, inventStyleId): EcoResStyle ecoResStyle; EcoResProductMasterStyle ecoResProductMasterStyle; select firstonly RecId from ecoResProductMasterStyle where ecoResProductMasterStyle.StyleProductMaster == product exists join ecoResStyle where ecoResStyle.RecId == ecoResProductMasterStyle.Style && ecoResStyle.Name == this.(dimFieldId); dimRecId = ecoResProductMasterStyle.RecId; break; } if (dimRecId) { dimName = EcoResProductMasterDimValueTranslation::getDescriptionOrDefaultDescription(dimRecId, userLanguageId); } return dimName; } } Now extend the form and add new control





If you cannot select data method from the drop down, compile class first and then it should be available.





Источник: https://ievgensaxblog.wordpress.com/...n-description/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.