AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 02.05.2010, 18:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,626 / 848 (80) +++++++
Регистрация: 28.10.2006
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;

}
And modify the code in the following location as show below

\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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: List of fixes that improve performance of certain features in Dynamics AX 2009 Blog bot DAX Blogs 0 13.10.2009 19:06
CRM DE LA CREME! Configuring Microsoft Dynamics CRM 4.0 for Internet-facing deployment Blog bot Dynamics CRM: Blogs 0 18.08.2009 11:05
gatesasbait: Dynamics AX 2009 SSRS and SSAS Integration Tips Blog bot DAX Blogs 3 09.07.2009 13:07
Developer for Microsoft Dynamics AX Certification Roadmap Blog bot DAX Blogs 1 13.05.2009 16:17
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 17:08.