Edit System Fields

Simple example for creating a record with systems fields set by code:

protected static server CaseLog createCaseLog(RefRecId _caseDatail, CreatedBy _createdBy, CreatedDateTime _createdDateTime)
{
    CaseLog caseLog;
    if(_createdBy && _caseDatail)
    {
        caseLog.initValue();
        caseLog.CaseRecId = _caseDatail;
        new OverwriteSystemFieldsPermission().assert();
        caseLog.overwriteSystemfields(true);
        caseLog.(fieldNum(CaseLog,CreatedBy)) = _createdBy;
        caseLog.(fieldNum(CaseLog,CreatedDateTime)) = _createdDateTime;
        caseLog.doInsert();
        caseLog.overwriteSystemfields(false);
        CodeAccessPermission::revertAssert();
    }
    return caseLog;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s