tag:blogger.com,1999:blog-1323778467050606749.post8957169226560711572..comments2024-02-05T10:39:26.283-05:00Comments on Adventures in Axapta world: How to compare two records of the same tablewojzehhttp://www.blogger.com/profile/17752044692176547068noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1323778467050606749.post-48482888244633189042013-10-03T13:54:26.460-04:002013-10-03T13:54:26.460-04:00Thank you Y.K. for your input!Thank you Y.K. for your input!wojzehhttps://www.blogger.com/profile/17752044692176547068noreply@blogger.comtag:blogger.com,1999:blog-1323778467050606749.post-58225262965353214812013-10-03T13:42:02.188-04:002013-10-03T13:42:02.188-04:00I implemented something similar on AX 2009 (albeit...I implemented something similar on AX 2009 (albeit with a different use - storing certain change history in the database). Some things I've noticed can be used to improve the code:<br /><br />A. strfmt will throw an uncaughtable error if the field is something it can't handle (like arrays). This will in particular hit AX 2009 and previous with their Dimension field arrays. DictField.arraySize() gives us the array, and if we want we can continue inside the array and find the needed difference (note that table.(fieldnum)[arrayIndex] syntax doesn't work as is - it gives us the entire array).<br /><br />B. If the table contains unusual type fields (container, class, etc.) same crash happens.<br /><br />C. areIdentical() isn't needed as is - we can just use buf2con() on both sides and compare.<br /><br />D. The current code loops over all fields once to get them into the list and again to get the differences. The second loop can be avoided if we use a different data class there - Set::create(list.pack()) actually works (on 2009 at least, didn't test on 2012), and then Set::difference().<br /><br />E. getTwoRecordsFieldList() may be better off with a server modifier and returning a container (list.pack()).<br /><br />F. selects should of course use firstonly.Y.K.https://www.blogger.com/profile/05517154664397348037noreply@blogger.com