12.12.2008, 13:05 | #1 |
Участник
|
DynaMihamAX: Label import problem in Dynamics AX 4.0
Источник: http://dynamihamax.blogspot.com/2008...ics-ax-40.html
============== Hi, About introduction: This is my first post, and I hope, I'll be able to post regularly in the future. Actually it depends on whether I encountered something I think to be useful for others as well or not. My topic will be Dynamics AX and related experiences. Sorry for my english if it's bad, it's only my second language. So, in medias res... Lately we were facing a problem regarding failing label import from XPO files. The scenario were always like this: DEV system -> Test system -> Live system The label import from the DEV to the TEST worked fine in most cases, but from the Test to the Live, it was a different story. Even though that on the import form the new labels were set to be imported (and make new label as well), several labels lost during each import. Last time, I managed to formalize the circumstances of the problem and today I found the bug in the system, which was responsible for this annoyance. Here is the problem description: each time when the import would import labels which were next in the label-file (current last label is @FOO111, the one to be imported is @FOO112), and there were at least one label which was different in the import than in the system for the same label-file (eg., @FOO99), the content of the newly created labels lost (with the label itself, of course). Today I was also experiencing this problem, and I took the time to hunt the bug down. Within ten minutes, I found and fixed it as well, the problem was in the importLabels() method in \Classes\SysImportElements. I changed it to the following: X++: // AOSrunmode::Client private str importLabels(LabelModuleId _labelModuleId) { str labelIdPack; LabelId newLabelId; ; if (importLabelLanguageSet.elements()) { while select tmpImportLabel // 2008.04.15 AttBa fix (label import annoyances) Begin // Detailed problem report: in some cases the newly // created labels (from import) got overwritten by the // imported labels (from the same import process). // Example: biggest labelid for FOO labelfile: @FOO419 // Labels to be imported: @FOO420, @FOO421 // Labels to be newly created: @FOO418, @FOO419 // Result with the old behaviour: // 1. @FOO418 created with labelid @FOO420 // 2. @FOO419 created with labelid @FOO421 // 3. @FOO420 imported to labelid @FOO420 // 4. @FOO421 imported to labelid @FOO421 // Result with the new behaviour: // 1. @FOO420 imported to labelid @FOO420 // 2. @FOO421 imported to labelid @FOO421 // 3. @FOO418 created with labelid @FOO422 // 4. @FOO419 created with labelid @FOO423 order by SysImportLabelAction // index LabelIdx // 2008.04.15 AttBa fix (label import annoyances) End exists join tmpImportAotLabel index PathLabelIdx where tmpImportAotLabel.LabelId == tmpImportLabel.LabelId exists join tmpImportAot index PathIdx where tmpImportAot.TreeNodePath == tmpImportAotLabel.TreeNodePath && tmpImportAot.Import { switch (tmpImportLabel.SysImportLabelAction) { case SysAotImportLabelAction::CreateNewLabel: newLabelId = ''; while select tmpSysLabel index LabelIdx where tmpSysLabel.LabelId == tmpImportLabel.LabelId { if (importLabelLanguageSet.in(tmpSysLabel.Language)) { newLabelId = sysImportLabel.importLabelInsert(_labelModuleId, tmpSysLabel.Language, tmpSysLabel.Label, tmpSysLabel.Description, newLabelId, tmpSysLabel.SysLabelApplModule); } } if (newLabelId) { if (labelIdPack) { labelIdPack += ','; } labelIdPack += tmpImportLabel.LabelId + ',' + newLabelId; } break; case SysAotImportLabelAction::DoNotImportLabel: break; case SysAotImportLabelAction::ImportLabel: while select tmpSysLabel index LabelIdx where tmpSysLabel.LabelId == tmpImportLabel.LabelId { if (importLabelLanguageSet.in(tmpSysLabel.Language)) { sysImportLabel.labelModify(tmpSysLabel.Language, tmpSysLabel.LabelId, tmpSysLabel.Label, tmpSysLabel.Description, tmpSysLabel.SysLabelApplModule); } } break; case SysAotImportLabelAction::UseExistingLabel: if (labelIdPack) { labelIdPack += ','; } labelIdPack += tmpImportLabel.LabelId + ',' + tmpImportLabel.ReplaceWithLabel; break; } } } return labelIdPack; } I re-did the import and puff - our problems are gone, labels have been imported properly. Hope you'll also find it useful. As usual: I'm not liable for any damage this code takes on your system, import it for your own responsibility in your test system, etc...</span> Источник: http://dynamihamax.blogspot.com/2008...ics-ax-40.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|