function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steven Vawdrey 13Steven Vawdrey 13 

I need to add text to a formula field when checkboxes are checked

When specific checkboxes are checked on our Contact object, I need a formula field to be populated/appended to with specific values. For example, if checkbox 1 is checked, I need the formula field to include "One". If another checkbox is also checked, I need that value appended to the first value in the formula field. For example, if both checkbox 1 and checkbox 2 are checked, the formula field should populate with "One Two" (on separate lines, if possible.) 

I have eight checkboxes that will affect the value in the formula field (formula because I want the value to be there when a user visits the contact, not after creating or editing the record.

Thanks so much for any help you can provide.
Alain CabonAlain Cabon
Hi,

There is no response here until now perhaps because your need is not clear (formula field? height checkboxes?)

User-added image

We could use a picklist ( multi-select ) instead of "the formula field which should populate with "One Two" (on separate lines, if possible.)"

What feature is missing using a simple picklist ( multi-select ) as above?

Best regards
Alain
HARSHIL U PARIKHHARSHIL U PARIKH
This can be done via standard but I think you would run into the charactor limitation.

You can do this via trigger and it would start something like this:
Trigger Checkbox on Contact(Before Insert, Before Update, After UnDelete){
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Contact con : Trigger.New){
        
            // This checks if checkbox 1 is not null but all others are null
            If(con.Checkbox_1 != NULL && 
                    (con.Checkbox_2 == null && con.Checkbox_3 == null && con.Checkbox_4 == null && con.Checkbox_5 == null && con.Checkbox_6 == null && con.Checkbox_7 == null && con.Checkbox_8 == null))
            {
                con.Custom_Field__c = 'One';
            }
            
            // This checks if checkbox 2 is not null but all others are null
            else If(con.Checkbox_2 != NULL && 
                    (con.Checkbox_1 == null && con.Checkbox_3 == null && con.Checkbox_4 == null && con.Checkbox_5 == null && con.Checkbox_6 == null && con.Checkbox_7 == null && con.Checkbox_8 == null))
            {
                con.Custom_Field__c = 'Two'
            }
            
            else If(){
                // Now do it for when Checkbox_4 is != null then con.Custom_Field__c = 'Four';
            }
            else If(){
                // Now do it for when Checkbox_5 is != null then con.Custom_Field__c = 'Five';
            }
            else If(){
                // Now do it for when Checkbox_6 is != null then con.Custom_Field__c = 'Seven';
            }
             else If(){
                // Now do it for when Checkbox_7 is != null then con.Custom_Field__c = 'Eight';
            }
             else If(con.Checkbox_1 != NULL && con.Checkbox_2 != NULL &&
                    (con.Checkbox_3 == null && con.Checkbox_4 == null && con.Checkbox_5 == null && con.Checkbox_6 == null && con.Checkbox_7 == null && con.Checkbox_8 == null))
            {
               con.Custom_Field__c = 'One' + '\n\' + 'Two'
            }
            
            /* Same thing for all other conditions such as,
                When checkbox 1 is not null and checkbox 3 is not null and all others are null
                when checkbox 1 is not null and checkbox 4 is not null and all others are null
                when checkbox 1 is not null and checkbox 5 is not null and all others are null
                when checkbox 1 is not null and checkbox 6 is not null and all other are null
                when checkbox 1 is not null and checkbox 7 is not null and all other are null
                when checkbox 1 is not null and checkbox 8 is not null and all other are null
                when checkbox 2 is not null and checkbox 3 is not null and all other are null
                when checkbox 2 is not null and checkbox 4 is not null and all other are null
                when checkbox 2 is not null and checkbox 5 is not null and all other are null
                
            */
        }
    }
}
If this answers your question then please mark it best!