OverwriteSystemFields(boolean)

I need to do some sort of manual EDI and need to assign a specific value to the system CreatedDate field. I remember about this property method but always forgot the implementation. The trick is we can't do a simple system field assignment. So I'll put it here to remind myself.

CustTable custTable;

custTable.overwriteSystemFields(true);
custTable.(fieldNum(CustTable,createdDate)) = [custom date];

custTable.insert();

Comments

  1. Hi

    I'm trying to do this on a customised table (CommentsList):

    CommentsList cl;
    ;
    new OverwriteSystemfieldsPermission().assert(); cl.overwriteSystemfields(true);
    cl.(fieldNum(CommentsList,modifiedBy)) = 'newlogin';
    cl.update();

    but I get this error:
    Request for the permission of type 'OverwriteSystemfieldsPermission' failed.
    (S)\Classes\OverwriteSystemfieldsPermission\demand
    (S)\Classes\xRecord\overwriteSystemfields
    (C)\Jobs\UpdateModifedByTest - line 6

    Any ideas?

    Thanks.

    ReplyDelete
  2. The reason why exception is appeared is performing depicted piece of code on client side. But it needs to be run on application server side instead. Thus you should encompass it into server static method or instance method which is performing on AOS.

    ReplyDelete
  3. this code should be with in class which should run on server

    ReplyDelete

Post a Comment