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
Aurora Ganguly 10Aurora Ganguly 10 

Activate Custom button on tick of checkbox

Hi All,
I have a custom object say order,
in that i have created two buttons , create KOT and create BOT button at the same time i have created two custom checkbox field KOT generated and BOT generated , now initialy what is happening on click of the button it is working but i want  at first those two checkbox should be ticked then only the two button should work otherwise not .. 

plz share your views. 
Best Answer chosen by Aurora Ganguly 10
Amit Singh 1Amit Singh 1
If you want to enable/disable button on Detail Page as per the checkbox values. Using Salesforce Standard functionality you can not do this for this you need to create a custom page where you can put the conditions.

Thanks,
 

All Answers

Amit Singh 1Amit Singh 1
If you want to enable/disable button on Detail Page as per the checkbox values. Using Salesforce Standard functionality you can not do this for this you need to create a custom page where you can put the conditions.

Thanks,
 
This was selected as the best answer
Varun SinghVarun Singh
Hi Aurora ,

I Have  created and tested in my org
Just  use this code for  your  task
its  work well!
 
<apex:page controller="Sample" >
<apex:form >
    <apex:pageBlock id="pg" >
        <apex:pageblockSection >
            <apex:pageblockSectionItem >Check it to view the button:</apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
                <apex:inputCheckbox value="{!option1}" >
                    <apex:actionsupport event="onclick" action="{!change}" reRender="pg"/>
                </apex:inputCheckbox>  
                <apex:inputCheckbox value="{!option2}" >
                    <apex:actionsupport event="onclick" action="{!change}" reRender="pg"/>
                </apex:inputCheckbox>               
            </apex:pageblockSectionItem>            
        </apex:pageblockSection>
        <apex:pageBlockButtons location="bottom">
             <apex:commandButton value="Submit" rendered="{!bool2}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockButtons location="bottom">
             <apex:commandButton value="Submit" rendered="{!bool1}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>    
</apex:page>



Apex Controller:
 
public class Sample 
{
    public Boolean option1 {get;set;}
    public Boolean bool1 {get;set;}
    public Boolean option2 {get;set;}
    public Boolean bool2 {get;set;}    
    public Sample()
    {
         bool1 = false;
         bool2 = false;
    }
    public void change()
    {
        if(option1 == true)
        {
            bool1 = true;

        }
        else
        {
            bool1 = false;
        }
        if(option2 == true)
        {
            bool2 = true;

        }
        else
        {
            bool2 = false;
        }
    }
}

Output:

User-added image


User-added image

If its work well  please select my answer as  best answer