14

Can anyone explain the difference between DescribeFieldResult isCreateable and isUpdateable methods? Seems to me that isCreateable should apply only to an object, not to a field, but the documentation says "Returns true if the field can be created by the current user".

Is it useful only for fields like CreatedDate when Create Audit Fields is enabled, to signify that the field can take data when the record is created but it can’t be edited later?

1
  • 1
    Master-Details can't be modified after initial creation of the record so that could be one situation where this makes sense (well, unless you flag the relationship as reparentable, it's a "fairly new" feature (2 years old or so?)). No idea if it's actually reflected in these describe results.
    – eyescream
    May 29, 2014 at 17:10

2 Answers 2

19

The isAccessible, isCreateable, and isUpdateable properties on DescribeFieldResult actually incorporate both Object Security and Field Security information for the given Field and its Object. Essentially it's a two-tier result --- first the Object's Security is considered, then additional Field properties are considered.

In general, if a User has Create and Edit rights on an Object, then all of its Createable fields will be Updateable as well as long as the running User has Field Level Security Edit rights to that field.

But this is not always true. The principal exception is for Master/Detail fields. Master/Detail fields will be Createable, but not Updateable, unless you have "Allow Reparenting" enabled on the Master/Detail field.

For instance, if a User can Create Cases, but not Edit them, then all Fields on Case will return false for isUpdateable, regardless of Field type or Field Level Security. Object security will trump.

Case.Subject.getDescribe().isAccessible() --> true Case.Subject.getDescribe().isCreateable() --> true Case.Subject.getDescribe().isUpdateable() --> false

If a User has both Create and Edit on the Case Status field, but can only View the field via Field Level Security, not Edit it, then both Createable and Updateable will be false:

Case.Status.getDescribe().isAccessible() --> true Case.Status.getDescribe().isCreateable() --> false Case.Status.getDescribe().isUpdateable() --> false

Now let's take a custom field, say a Position__c reference field on a Job_Application__c record. If Position__c is Master/Detail with Allow Reparenting FALSE, and the user has read/edit rights via Field Level Security, then here's what you'll get

Job_Application__c.Position__c.getDescribe().isAccessible() --> true Job_Application__c.Position__c.getDescribe().isCreateable() --> true Job_Application__c.Position__c.getDescribe().isUpdateable() --> false

But if Position__c is Master/Detail with Allow Reparenting TRUE, and the user has read/edit rights via Field Level Security, then here's what you'll get

Job_Application__c.Position__c.getDescribe().isAccessible() --> true Job_Application__c.Position__c.getDescribe().isCreateable() --> true Job_Application__c.Position__c.getDescribe().isUpdateable() --> true

0

I believe that if a User can create the Object, that user can set the value of any creatable field. If the user does not have edit access to the field, then once the record is created, that user won't be able to change it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.