18.05.2011, 12:11 | #1 |
Участник
|
axblog4u: X++ Script to renamePrimaryKey across companies
Источник: http://axblog4u.wordpress.com/2011/0...oss-companies/
============== Hey Guys During data upgrade to AX2012 we had issue in ‘Product Upgrade’ preprocessing checklist. Validation errors were observed due to presence of same item in different companies with different ‘DimGroupId’ or ‘ItemType’ values. Only way left to resolve the issue was by renaming the ‘ItemId’ of these items. So we renamed all the items which are of type ‘StopItem’ to ‘%Old Item Name’. Accordingly the String size of ‘itemIdBase’ and ‘EcoResProductNumber’ EDTs were increased to 30 to avoid the truncation of ‘ItemId’ and ‘ProductNumber’. The best option left to optimize the work load instead of manually updating the item was to use the renamePrimaryKey method. X++: static void renamePKInventTable() { #File #define.prefixItem('Old') InventTable inventTable; container getCompanyList; int i; DataAreaName id; container getCompany() { dataArea dataArea; // Virtual Companies should not be added. while select dataArea where dataArea.isVirtual != NoYes::Yes { getCompanyList += [dataArea.id]; } return getCompanyList; } ; getCompanyList = getCompany(); for(i = 1; i<= conlen(getCompanyList); i++) { id = conpeek(getCompanyList, i); changeCompany(id) { inventTable.clear(); while select inventTable where inventTable.RMCItemType == RMCItemType::StopItem && inventTable.dataAreaId == id && !(inventTable.ItemId like 'Old*') { ttsbegin; inventTable.ItemId = #prefixItem + #delimiterSpace + inventTable.ItemId; inventTable.renamePrimaryKey(); if(inventTable) { inventTable.selectForUpdate(boolean::true); inventTable.ItemName = inventTable.ItemId; inventTable.NameAlias = inventTable.ItemName; inventTable.update(); } ttscommit; } } } }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось Poleax; 18.05.2011 в 14:01. Причина: оформление |
|