I am running a batch process that is marked without sharing
.
I would like to to take one course of action if the batch process can update a particular field, and another if not.
For example:
if (canUpdate(fld)) {
updateRecord();
} else {
cloneRecordAndUpdateThat();
}
The naive way of writing canUpdate()
is to use fld.getDescribe().isUpdateable()
. However, that will always look at the current user's permissions. I specifically want to override user permissions, but sometimes fld
is not updateable on a system level (e.g., the "master" field on a master-detail relationship that cannot be reparented).
How do I discover if "god-mode" without sharing
permissions can update that field?
reparentableMasterDetail