How to modify a record "CreateDateTime"?

Hello,

I have a table that has existing record. Now I turn on the property “CreateDateTime” to Yes.

All existing records is having the same “CreateDateTime” as today.

How can I modify the existing record “CreateDateTime” field?

Thanks in adavance.

Hi,

Make a processing report on table and modify the records for “CreateDateTime” field.

regards\ vimal

Hello,

You need to use ‘overWriteSystemFields’ method to update system fields. Have a look under Classes\ReleaseUpdateDB41_Basic\updateBatch for inspiration.

Regards,

hi,

how the sytem knows the createddatetime of the previous records???

regards

Kranthi

Hello,

I try to use the OverWriteSystemFields method, but when I run the job, it prompt error as

Request for the permission of type ‘OverwriteSystemfieldsPermission’ failed.
(S)\Classes\OverwriteSystemfieldsPermission\demand
(S)\Classes\xRecord\overwriteSystemfields

My job is:

permissionSet.add(new SkipAOSValidationPermission());
permissionSet.add(new OverwriteSystemfieldsPermission());
CodeAccessPermission::assertMultiple(permissionSet);

ttsbegin;
inventJournalTable = inventJournalTable::find(“02”, true);
inventJournalTable.overwriteSystemfields(true);
inventJournalTable.(FieldNum(InventJournalTable, CreatedDateTime)) = inventJournalTable.PostedDateTime;
inventJournalTable.doUpdate();
inventJournalTable.overwriteSystemfields(false);

CodeAccessPermission::revertAssert();
ttscommit;

Do you know the reason for fail?

Hi,

Try to update the createddatetime field directly from database…

Regards

kranthi

Hello Kranthi,

Yes, finally I give up X++. [:S]

I did the update in SQL.