1-844-696-6465 (US)        +91 77600 44484        help@dezyre.com

How to prevent a field from being editable



0
Hi, I'm practicing modifying the Position object in the Force.com Fundamentalls book. I have both Close Date and Days Open defined to be read-only (non-editable) fields. It works properly for Days open (which is a number), but not for Close Date (which is a Date type).

When I change Close Date, it turns red, then accepts the change. Why is it allowing me to edit this, because both the field-level security, and the field property on the form are specified as "Read Only"

3 Answer(s)


0

Researching the Internet I found if you don't want any users to be able to change a value, you should use Field Level Security (FLS) to make it read-only on a profile-by-profile basis:

1. Go to the object's field page under Setup
2. Click on the view link for the field
3. Click the Set Field-Level Security button
4. Change the field to read-only for the appropriate profiles (You would need to change to appropriate profile to test)

Note: Only use a validation rule for this when the field should be read-only only under certain circumstances; for blanket coverage modifying FLS is more appropriate.
Note: To set it up so the user can insert an initial value but not update an existing one you can use the following validation rule:

AND(ISCHANGED(Field__c), NOT(BlANKVALUE(PRIORVALUE(Field__c)))

This will allow the user to enter a new value assuming no prior value has been entered, but once a value is set, it is locked in place.

0

In my example, I do have FLS set to read-only, for all profiles. I also have the field set to read-only on the page layout. When I create a new instance of my custom object, I'm still able to click on the calendar and enter a date.

I was wondering if there's something different about dates, where you can't prevent this from happening.

0

Hi Keith, Sorry for the late reply, I am little busy these days in my sister's wedding. So to answer your question, you have system admin profile and remember when we discussed profiles I told you guys that System Admin profile can see all data because it has View All and Modify All permission by default and also have a permission to view read only data. So if you want to see your changes then please login from any other profile.

Let me know if you still have any doubt.

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password