02.05.2010, 18:05 | #1 |
Участник
|
kamalblogs: Solving the Id conflict issue during import of XPO in Dynamics Ax
Источник: http://kamalblogs.wordpress.com/2010...n-dynamics-ax/
============== When you try to import an XPO with an Id conflict(Two different components sharing the same name), then Ax prompts with an dialog. This dialog informs the conflict and skips importing the specific component. This is specifically more trouble some when you are developing application connected to TFS. Especially when you synchronize an component with ID conflict the synchronize skips it and to get the object again you will have to either do a Checkout/checkin from another machine or do a forced synchronize. So i was often made to spend more time because of these issue. To avoid this after some time i developed a small workaround that worked well and served the cause. Here it goes… it is basically the following line which makes the call to the function that imports as well as show the dialog. \Classes\SysImportElements\importElements – Line 51 “flag = infolog.importElement(_exportId, tmpImportAot.UtilFileType, tmpImportAot.UtilElementType, name, tmpImportAot.FilePos, flag);” What i did was built a small condition that validates if there is any existing component with the same Id and if so, then it asks the user if it can delete and import the new one. If yes then it deletes the existing one and then imports the new component. This way the dialog allows you to perform an action rather being just an blocking prompt information. Here is the code which does the job. For the purpose of convenience i added this as an method that returns a boolean variable and modified the actually call with an if condition. X++: //This method is helpful in finding ID conflicts earlier. //Through this method we can avoid the VSS error where an element is updated in the file system but not in the AOT protected boolean I4C_validateImport(TmpAotImport _tmpImportAot) { UtilIdElements elements; str userString; TreeNode node; TreeNode parentNode; ; select firstonly elements where elements.id == _tmpImportAot.UtilElementId && elements.recordType == _tmpImportAot.UtilElementType && elements.name != _tmpImportAot.TreeNodeName; if (elements.RecId) { userString = strfmt("Importing AOT object '%2' with Id %1 is already occupied by element '%3'. Do you want to delete the existing tree node object '%3' and import '%2'? Cancel will abort the import.", _tmpImportAot.UtilElementId, _tmpImportAot.TreeNodeName, elements.name); if (DialogButton::Ok == Box::okCancel(userString, DialogButton::Ok, "Id conflict")) { node = xutilIdElements::getNode(elements); if (node) { node.AOTdelete(); parentNode = TreeNode::findNode(SysTreeNode::pathParent(node.treeNodePath())); if (parentNode) { parentNode.AOTrefresh(); } return true; } } return false; } return true; } \Classes\SysImportElements\importElements – Line 51 X++: if (this.I4C_validateImport()
{
flag = infolog.importElement(_exportId, tmpImportAot.UtilFileType, tmpImportAot.UtilElementType, name, tmpImportAot.FilePos, flag);
} Источник: http://kamalblogs.wordpress.com/2010...n-dynamics-ax/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
03.05.2010, 00:19 | #2 |
Участник
|
Хмм, все не читал. Но похоже он не знает про галочку "Импортировать без идентификаторов"
|
|
|
За это сообщение автора поблагодарили: mazzy (2). |
03.05.2010, 07:20 | #3 |
Участник
|
Hi Kashperuk, Thanks for the comment. I think you are referring to the "import without id values" option in the import dialog. The code that i have written here is very much useful when you work in a TFS based environment. In TFS based environment the synchronize option automatically starts import without any dialog. So you give a miss of importing the object when you get the original system dialog.
|
|
|
|