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
Emine YumerovaEmine Yumerova 

Checkbox - value

Hello all ,I tried to find the solutions for my idea , but after many unsuccessful attempts  I lost my power.

Can somebody help me ? I have 31 check box type  fields  in Object  Contract  my collegues need to have option to choose one them or combination of this fileds , but the fields has a different value for example: 
IF A1 = True the value can be 1 or 2 (here will be perfect when they click on choosen check box automatically get the value 1 with idea to change manually from 1 to 2 ) the logic it is the same for any other created check box.
IF A2 = True the value can be 1 or 2
IF A3 = True the value can be 1 or 2 
The idea is after to have  a report which one of this our customers prefer.
I tried with check box , but it is a slowly process to choose for every one , on the other side when I click by defult value one every one of this fileds has a value 1 , but it is not true.

So after I tried with process builder , again unsucessfull ,becasue on Quantity have an option to choose only 1 , what happened when I want more than one for A1 , please somebody can help if know or have an idea!

Many thanks !
HARSHIL U PARIKHHARSHIL U PARIKH
Are you saying you need to make a validation on to make at least one of the checkbox field required?
If yes,

I would suggest to make a a formula field named Checking__c with return type of TEXT and it will have formula something like,
 
If(A1__c == TRUE, "TRUE", null) + " " + 
If(A2__c == TRUE, "TRUE", null) +  " " + 
If(A3__c == TRUE, "TRUE", null) +  " " + 
If(A4__c == TRUE, "TRUE", null) +  " " + 
If(A5__c == TRUE, "TRUE", null) +  /// Up to 21 times for all fields.

Once done, make a validation rule which would say 
 
! CONTAINS("TRUE",  Checking__c )

Means whenever there is no TRUE inside that formula then it will throw an error. This way at least one checkbox from those 21 checkboxes needs to be true in order to save the record if none of them are true (means if all of them are unchecked) then record would not save.

Hope this helps!
Emine YumerovaEmine Yumerova
I am not sure and I feel very confused , 

Maybe you give  me the advice how to resove the problem , but I do not understand ,
The idea is that sometimes we choose only A1 and this position when choosen to have by default value 1 with idea to change , but how I can insert the value , how I can say please when you choose A1 and click on it give the value 1 / oder option for  my colleagues to choose  2 manually .In the same moment they need to have an option to choose the other position A2 with value 3.This number decsribe the quantity .So sometimes they choose a combination of them .

And on the other side if you would suggest me to make a formula it is a wrokflow rules or process builder . 

Sorry maybe my questions is stupid for you , but I am new and it is very hard for me to understand right what is happended and how I can achieve the best result in this quetions.

Many thanks for the time to explain me everything hope to see your advice !
Emine YumerovaEmine Yumerova
User-added image
If it is a validation rule why it is uncorrect
SudipkMondalSudipkMondal
Hello Emine,
Sorry, but I have some very basic questions on your requirement.
Are there 31 different fields in addition to the 31 checkboxes which you are trying to update?
    Ex:
    When you check on A1 checkbox --> It autopupulates Field F1 with the value 1 which should remain editable and should accept either 1 or 2.
    When you check on A2 checkbox --> It autopupulates Field F2 with the value 1 which should remain editable and should accept either 1 or 2.
    and so on.
Or,
There is only 1 field that would contain the value 1 or 2 where 1 would get auto-populated and it should allow to user to enter a value to the textbox and only 1 or 2 is accepted?

Regards,
Sudip Kr. Mondal
Emine YumerovaEmine Yumerova
Hello Sudip , 

Exactly they are 31 different check box fileds which I tried to update only when my collegues click on choosen the other need to stay with value 0 , only the choosen fileds need to have value different value 1 or 2 ..
If you need for more details I am ready to try to expalin again , becasue for me is a little hard and maybe I will confuse you !

Thanks for the response
Waqar Hussain SFWaqar Hussain SF
Hi Emine,

After reading over your requirements it seems you want to show dynamically picklist values based on checkboxes.
For example if user select A1 to true, then the picklist will show values 1 and 2. Similar for other checkbox vlaues. 

For this requirement you will have to develop a custom VF page, which will show all checkboxes and will renderd picklist fields based on checkboxes selected. 

I hope this will help you to go on your right path.
 
Emine YumerovaEmine Yumerova
Hello , 

But can you give me a little more details how can I try to create a VF page and picklist value for all checkbox.

Many thanks for the help
Waqar Hussain SFWaqar Hussain SF
You can define dependent picklist values, based on the checkbox selected. 
And then can develop a page to show fields and the you will have to validate user inputs using apex.

For Dependent picklist values and creating VF page, please see the below article.
http://https://salesforce.stackexchange.com/questions/173988/how-to-display-a-picklist-based-on-the-value-chose-on-another-picklist
Emine YumerovaEmine Yumerova
It is very hard for me to understand for first I need to have 31 picklist fileds and then create a VF page or so sorry for my qiestons , I really try to understand how it works
Waqar Hussain SFWaqar Hussain SF
Goto Setup => Objects and then click on your object Name
To define the field dependencies for Subcategories:

From the object management settings, go to the fields area.
1- Click Field Dependencies.
2- Click New.
3- Choose CheckBox 1 field as a controlling field, and Subcategories as a dependent field.
Click Continue.
4- Each value in the controlling field (from CHECKBOX_1__c}) is listed in the top row and each value in the dependent field (from Picklist 1) is displayed in the column below it.

After creating dependent field, Here is a sample for 1 checkbox and 1 dependent field, using standard controller.
 
<apex:page standardController="YOUR_ObJECT_NAME__c" >
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Information" >
            <apex:inputField value="{!YOUR_ObJECT_NAME__c.CHECKBOX_1__c}"/>
            <apex:inputField value="{!YOUR_ObJECT_NAME__c.PickList_Field_1__c}"/>
            ...
            
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

similar to this you can add multiple checkboxes and can validate fields using extension on the page.

 
Emine YumerovaEmine Yumerova
User-added image

And then how can I insert my Object in the makred fields that you send to me can you help me ?
It is very interesting process , hope it is in a right way ....
Many thanks 

Kind Regards, 
 
Waqar Hussain SFWaqar Hussain SF
You have to first define the checkbox field as a controling field and the picklist field as dependent field as I described earlier.

Then you can use below code to update contract record.
 
<apex:page standardController="Contract" >
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Information" >
            <apex:inputField value="{!Contract.Check_Box_1__c}"/>
            <apex:inputField value="{!Contract.picklist_1__c}"/>
            
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

You willl be using this page as a below URL
e.g
https://waqar-dev-ed--c.ap1.visual.force.com/apex/Test1?Id=80090000000WfRZ
Your instance URL/apex/PAGENAME?Id=ContractID