Thursday, January 28, 2010

Field security and record templates

We came across an issue where a user that does not have access to edit a mandatory field on a table was not able to save a record created from a template that has the field predefined.

Consider the case where we want to allow a user to create items but we do not want him to be able to modify the item group. We prevent the user from modifying the field through security. All the items are created through templates which have an item group already defined... The problem is when the new record is created from the template, before copying the value over, it checks if the user has edit access on the field.

To avoid this problem, a simple modification can be made in ClassFactory/createRecord

The call to
sysRecordTemplate.createRecord();

needs to be modified to
sysRecordTemplate.createRecord(false);

This will ignore the AllowEditOnCreate (Edit access in security) property when transferring over the values from the template to the new record.