1

We have SFDC - Employee Integration with external HR System, Question is when we receive back the ‘Employee Identifier’ from HR System, I need to make the employee record read only? pls suggest suitable soultion.

Thanks!!

1 Answer 1

1

The easiest way to do this would be to add a checkbox field Is_Read_Only__c. Then put a trigger on the Object. Before update, look at that field, and if it is true, stop the operation for that record by adding an error.

for(Id id : Trigger.newMap.keySet()){
    //Make sure this isn't the update that is setting the flag for the first time. 
    if(Trigger.oldMap.get(id).Is_Read_Only__c && Trigger.newMap.get(id).Is_Read_Only__c){
        Trigger.oldMap.get(id).addError('Record Id ' + id = ' is marked as read-only and cannot be edited);
    }
}

Not the answer you're looking for? Browse other questions tagged .