Error executing code: Wrong argument types for comparison.
(C)\Data Dictionary\Tables\SysDataBaseLog\Methods\getDataAslist - line 28
(C)\Forms\SysDatabaseLog\Methods\buildContents - line 30
(C)\Forms\SysDatabaseLog\Data Sources\DBHistory\Methods\active - line 7
The actual issue is this, when we were in AX 3.0, we made a chance to a record, which was logged to Tables\SysDatabaseLog and had the ModifiedDate stored as a type of Date. Somewhere along the AX 3.0 to AX 4.0 to AX 2009, this data wasn't upgraded properly.
When the database log compare form tries to work with it, it's expecting to work with two utcDateTime objects for comparison, but it gets a Date and fails.
You can put this code in Tables\SysDatabaseLog\getDataAslist at around line 30 and see the issue in the debugger:
if (typeOf(conpeek(tmp, 2)) == Types::Date &&
dictField.baseType() == Types::UtcDateTime)
{
breakpoint;
}
You can write a hack with conPoke(...) and DateTimeUtil::newDateTime(...) to replace the Date with a utcDateTime, but you'll run into issues in other methods. The best thing to do is correct the data and I wrote a job to do just that. One specific thing to note, this is just proof of concept code...for our actual corrective actions, I wrote a class and table to do batches for various reasons since we have nearly 4 million records. As always, run at your own risk and test. Enjoy:
static void DatabaseLogFix(Args _args) { SysDataBaseLog log; container tmp; container newData; SysDictField dictField; fieldId fieldId; int i, idx; boolean updateCon; boolean updateData; Counter counter; #Properties; ; //select firstonly log where log.RecId == 5638018469; ttsbegin; while select forupdate log order by CreatedDateTime, RecId { updateData = false; if (typeof(conpeek(log.Data, 1)) == Types::Container) //Version 3.0 format { newData = log.Data; for (i=conlen(log.Data); i; i--) { updateCon = false; tmp = conpeek(log.Data, i); fieldId = conpeek(tmp, 1); dictField = new SysDictField(log.Table, fieldId); if (dictField) { if (dictField.name() == #PropertyModifiedTime || dictField.name() == #PropertyCreatedTime) { continue; } // Type mismatch for "New" value if (typeOf(conPeek(tmp, 2)) != dictField.baseType()) { // If it's a date that should be a utcDateTime, upgrade it if (typeOf(conpeek(tmp, 2)) == Types::Date && dictField.baseType() == Types::UtcDateTime) { tmp = conPoke(tmp, 2, DateTimeUtil::newDateTime(conPeek(tmp, 2), 0)); updateCon = true; } // Otherwise throw an error else { info(strfmt("[RecId %1][TableID %5][FieldId %2][2 NEW] Type mismatch (%3/%4)", log.RecId, fieldId, typeOf(conPeek(tmp, 2)), dictField.baseType(), log.table)); } } // Type mismatch for "Old" value if (typeOf(conPeek(tmp, 3)) != dictField.baseType()) { // If it's a date that should be a utcDateTime, upgrade it if (typeOf(conpeek(tmp, 3)) == Types::Date && dictField.baseType() == Types::UtcDateTime) { tmp = conPoke(tmp, 3, DateTimeUtil::newDateTime(conPeek(tmp, 3), 0)); updateCon = true; } // Otherwise throw an error else { info(strfmt("[RecId %1][TableID %5][FieldId %2][3 OLD] Type mismatch (%3/%4)", log.RecId, fieldId, typeOf(conPeek(tmp, 3)), dictField.baseType(), log.table)); } } if (updateCon) { updateData = true; newData = conPoke(newData, i, tmp); } } } if (updateData) { counter++; log.Data = newData; log.update(); } } } ttscommit; select count(RecId) from log; info(strfmt("%1 updates made against %2 records", counter, log.RecId)); }
I just had a case where I got a string value (Customer or Vendor ID) in the log for a custom float field on InventTable. AX 2009 from the start, apparently you don't need to upgrade to get corrupt data in DatabaseLog.
ReplyDeleteThat's strange. I'd guess you might have had added a custom string field to a table, typed some data, then changed the string field to a float. You would receive a synchronization warning that says "Warning this field will be dropped and recreated" or something to that sort.
DeleteAll is well, except that if you had DB logging turned on, that string field was recorded in the DB log, then it is now a float and it is a type mismatch. This would explain your error, but it's just my guess.
Very nice blog you have hhere
ReplyDeleteDengan menyediakan berbagai game yang modern, jujur, adil, merakyat dan nyentrik. Kini BANDARBOLA855 hadir untuk menemani keseharian anda dengan berbagai event dan kesempatan meraih kemenangan besar. rtp bandarbola855
ReplyDeleteOh my goodness! an excellent article dude. Many thanks However I am experiencing trouble with ur rss . Do not know why Not able to enroll in it. Will there be any person obtaining identical rss dilemma? Anyone who knows kindly respond. Thnkx Pink salt Trick
ReplyDeleteYour talent is really appreciated!! Thank you. You saved me a lot of frustration. I switched from Joomla to Drupal to the WordPress platform and Ive fully embraced WordPress. Its so much easier and easier to tweak. Anyway, thanks again. Awesome domain! AuDifort
ReplyDeleteIt was any exhilaration discovering your website yesterday. I arrived here nowadays hunting new things. I was not necessarily frustrated. Your ideas after new approaches on this thing have been helpful plus an superb assistance to personally. We appreciate you leaving out time to write out these items and then for revealing your thoughts. pink salt trick
ReplyDeleteWhen do you think this Real Estate market will go back in a positive direction? Or is it still too early to tell? We are seeing a lot of housing foreclosures in Altamonte Springs Florida. What about you? Would love to get your feedback on this.
ReplyDeleteSoulmate sketch
A round of applause for your blog post. Awesome. 압구정가라오케
ReplyDelete