You need to sign in to do that
Don't have an account?
Bharath Samanthula
Lock fields when a check box is checked
Hi, I would like to know how to lock a field when a check box is checked. the field i would like to lock has picklist values. I tried validation rule but its not working. Any help?
2.Create a record type named locked picklist where you need to set the picklist field to read only(on the associated page layout), then write a trigger which will change the record type to locked picklist if checkbox is checked.
All Answers
2.Create a record type named locked picklist where you need to set the picklist field to read only(on the associated page layout), then write a trigger which will change the record type to locked picklist if checkbox is checked.
1. Visualforce Page:- You can simply use Javascript, using 'onchange' event you can disable the picklist field.
2. Standard Page:- There can be 2 ways:-
a. Write a validation rule formula as 'checkbox_field == true && ISCHANGED(picklist_field) '. In this case, visibly the picklist field won't be locked.
b. Create one more Record Type and one more Page layout (keeping the picklist field as read only) and assign the Page layout to the Record Type. Write a workflow which will update the record type when the check box will be checked.
First solution is preferable.
Please mark the answer as Best Answer if it really helped.
Write one validation :
trigger DemoCHK on Opportunity (before update) {
for(Opportunity opp:trigger.new)
{
if(opp.newCHK__c== true && (trigger.oldMap.get(opp.id).validatePickList__c!= opp.validatePickList__c))
{
opp.addError('RecordLocked');
}
}
}