I need to backdate the modified datetime of a particular table (not for the data reocord). How can i do this? i am using CUS layer of the dynamics ax 2009.
yourtable.overwriteSystemfields(true);
An example with custInovicejour
new OverwriteSystemfieldsPermission().assert();
custInvoiceJour.overwriteSystemfields(true);
custInvoiceJour.(fieldNum(CustInvoiceJour,modifiedDateTime)) = DateTimeUtil::utcNow();
custInvoiceJour.doUpdate();
CodeAccessPermission::revertAssert();
Hi XBB,
I executed the above code part by writing it in a job. but i got below error. please advice me what can i do?
(my account has admin privileges).
Request for the permission of type ‘OverwriteSystemfieldsPermission’ failed.
(S)\Classes\OverwriteSystemfieldsPermission\demand
(S)\Classes\xRecord\overwriteSystemfields
(C)\Jobs\Job43 - line 8
Set the code on a class an called from server side, here a code working…
This code has to be on a class…
static server void method1()
{
CustTable custTable;
new OverwriteSystemfieldsPermission().assert();
ttsBegin;
select firstOnly forUpdate custTable;
custTable.overwriteSystemfields(true);
custTable.(fieldNum(custTable,modifiedDateTime)) = DateTimeUtil::utcNow();
custTable.doUpdate();
ttsCommit;
CodeAccessPermission::revertAssert();
}
Thanks XBB,
It is working fine.
Further could you explain me how do i change the “Changeby” property in a AX table?
This field is modified everytime someone modified the object.
Of course. bu i want to back date it. How can i do this?
I heard about UtilIdElements table which contains all the ax table properties.
How can i update the modifieddatetime figure in that table?
//BGFindVATDiff is the name of my table
select forupdate UtilIdElements
where UtilIdElements.name ==‘BGFindVATDiff’;
ttsbegin;
UtilIdElements.modifiedDateTime = DatetimeUtil::date(); // this line of the code inorrect
UtilIdElements.doUpdate();
ttscommit;