Compare Tables Between Layers X++

Hi, I have request to create button in AX 2012 to compare all objects while importing project into AX.
I have used SysCompare class SilentCompare method and it works great for classes, forms etc but I have problems with tables. It always report that there is difference even if there isn’t. In debug i saw that Field ID (example in SYS Layer into which I am importing) has some value (#30001) and in XPO Layer Field ID is always 0 so it reports that those object are not the same. Can anyone help?

Do you have the same problem when doing the comparison through UI? I don’t have any problem with IDs in that case, so I think you are doing something wrong when calling SysCompare from code.

Nevertheless even through UI, I don’t get the result you want. For example, it shows a difference on AutoIdentification group fields (they’re not included in .xpo but they’re generated in AX).

I would export the object from AX to .xpo and compare .xpo files directly (probably by some external diff tool).

Hi, thanks for reply.
No. With UI it works correct. I know I am doing something wrong so I am asking if someone can help me to tell me what is correct way so I can fix my mistakes.
i have exported 2 tables and created 1 field in one of them so when I try to import it should detect changes in one and the other is not-modified. (Sorry for my bad explaining I hope you understand my problem). But it detect changes in both tables. In debug I saw its the ID that is 0.

Then show us the code that you need some help with.

I have only called the SysCompare::SilentCompare in standard way

SysCompare::silentCompare(SysUpgradeTreenode::newTreenode(treenodeInAot), SysUpgradeTreenode::newTreenode(treenodeInXpo));

I also tried with SysCompare.startCompare method

Also tell me one more thing before we start dealing with code: even if we resolve the problem with IDs, will it be of any use? Don’t you have the problem with AutoIdentification as well?

Yes it will. In this way it works for classes and forms and etc but I also need the DataDictionary.
No, i dont have problem(at least until now I didnt).

silentCompare() isn’t capable doing what you want. It merely compares string representations and it has no idea about the content, including IDs.

You would have to follow the way that the compare dialog uses, which analyzes AOT tree nodes and compares them one by one and handles properties in a special way. The logic for dealing with IDs is implemented in SysTreeNode.comparableTextListProperties().