Skip to main content
Hello,

 

We want to prevent users from editing account if a certain checkbox is set as true in the account itself. The check box is a custom field in the account. Is there a way to accomplish this? 
9 respostas
  1. 27 de abr. de 2014, 08:35
    Hi Yameen,

     

    You can do this in different ways but the ' ways ' actually depend on the Edition that you're on. Let me brief you the ways one by one:

     

    1. Creating a Validation Rule

     

    Supported Editions : All Editions

     

    Pre-Requisites : None

     

    The Validation Rule [1.1]  would look like this:

     

    AND(

    NOT(ISNEW()),

    $Profile.Name <> 'System Administrator',

    Checkbox_Field__c = TRUE

    )

    So in this case, the VR checks if the record is New or not. If it is not New and if person who hit the Save button after making some changes on the record is not a System Administrator then throw an Error. Now I just added the System Administrator for the sake of showing how the VR could be written. You can add as many

    allowed  Profile Names as you want like as below:

     

    AND(

    NOT(ISNEW()),

    $Profile.Name <> 'System Administrator',

    $Profile.Name <> 'Marketing User',

    $Profile.Name <> 'Sales User',

    Checkbox_Field__c = TRUE

    )

    Also, you could even look at Role Names instead of Profiles.

     

    Now, one caveat to this approach is that, the User will not know this until he/she hits the Save button.

     

    2. Switching Record Types with the help of Workflow Rules and Field Update

     

    Supported Editions : Enterprise Edition and above.

     

    Pre-Requisites : Availability of Record Types assigned to the appropriate Profiles.

     

    So the idea is this: Whenever the Checkbox is ' checked ', a Workflow Rule [2.1] observing for changes in this Checkbox Field will be evaluated successfully and as a result an Immediate Workflow Action of type Field Update [2.2] will be triggered which would change the RecordTypeId on the Account record in context.

     

    So you will have to create 2 Record Types [2.3] and will have to make sure that the Record Types when created are enabled for the appropriate Profiles too. The first Record Type will be associated to a Page Layout where all the required fields are editable as it was by default. The second Record Type will be associated to a Page Layout where all the fields will be marked Read Only on the Page Layout.

     

    So when the checkbox is checked the RecordType will be changed to the Record Type which is associated to the Read Only Page Layout by the Workflow Rule Field Update and when unchecked , the Record Type will be changed to the Record Type which is the default Page Layout or the one in which the required fields are all editable .

     

    [1.1]: Validation Rule (http://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_validation_rules.htm&language=en_US)

     

    [2.1]: Workflow Rule (http://help.salesforce.com/HTViewHelpDoc?id=creating_workflow_rules.htm)

     

    [2.2]: Field Update (http://help.salesforce.com/HTViewHelpDoc?id=workflow_defining_field_updates.htm&language=en_US)

     

    [2.3]: Record Types (http://help.salesforce.com/apex/HTViewHelpDoc?id=creating_record_types.htm)

     

    Best,

     

    Deepak
0/9000