In Salesforce I have an account. On that account I have a couple of fields that are populated from the PHP SDK after some processes run in the background. The PHP SDK updates a field on certain conditions, when that happens I also would like to lock down that field to read-only. Can I do this from the PHP SDK?
+2
A:
You want your "lock" on database (or in this case - on Salesforce) level, not on the PHP SDK level. Because otherwise malicious user will just grab Data Loader or Excel Connector and go on with his update bypassing your lock ;)
Try out the Salesforce Validation Rules or (if your logic is complex) a "before update" trigger.
Example validation rule could look like:
condition:
AND(
ISPICKVAL(PRIORVALUE(Type),"Technology Partner"),
ISCHANGED(Type),
$Profile.Name <> "System Administrator"
)
error message to be displayed:
After Type has been set to "Technology partner" only Administrators can modify this field.
This is just a starting point, feel free to experiment and fine-tune. You can also disable this rule after migration.
Check out the Validation Rules functions help page or intro to Validation Rules for more goodies. The ISCHANGED() function should be especially useful for you.
eyescream
2010-07-27 21:00:53
This looks like what I need, will test and confirm
Phill Pafford
2010-07-28 12:01:05
Hmm is there a way to say, if blank can edit (Text field), else lock?
Phill Pafford
2010-07-28 15:15:46
"AND(ISCHANGED(field), LEN(PRIORVALUE(field)) <> 0)" for example. I've decided to examine non-zero length of previous value, but there are many related functions that might suit you better: blankvalue(), nullvalue(), isblank(), isnull().
eyescream
2010-07-28 16:54:41
Would this validation rule apply to the API user? As I also need to allow the API user to update the record but not a normal user
Phill Pafford
2010-07-30 16:21:12
eyescream
2010-07-30 17:54:15