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
AbAb 

Global chekbox to control a logic of function execution

Hello,
I want to create a global checkbox which if true will exute code block one.
What is simplest way to achieve it , please ?
If(Global checkbox == True){
    @AuraEnabled(cacheable=true)
    public static string FucntionName(){
       //Logic
   }
}else{
    @AuraEnabled
    public static string FucntionName(){
       //Logic
   }

}
thank you for advice
Best Answer chosen by Ab
ShirishaShirisha (Salesforce Developers) 
Hi Sandrine,

Greetings!

In order to achieve this you would need to create the global picklist field on UI then you can use it in the apex class to run the code based on the value of the picklist value:

https://help.salesforce.com/apex/HTViewHelpDoc?id=sf.fields_creating_global_picklists.htm&language=th

https://developer.salesforce.com/forums/?id=9060G000000XZmkQAG

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
 

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Sandrine,

Greetings!

In order to achieve this you would need to create the global picklist field on UI then you can use it in the apex class to run the code based on the value of the picklist value:

https://help.salesforce.com/apex/HTViewHelpDoc?id=sf.fields_creating_global_picklists.htm&language=th

https://developer.salesforce.com/forums/?id=9060G000000XZmkQAG

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
 
This was selected as the best answer
Vishwajeet kumarVishwajeet kumar
Hello,
You can use a Input element of checkbox type, associate its value = true/false to JS controller and use it for verification in method. Input checkbox value can be updated in JS Contorller using "onchange" event method on input checkbox, event(event.target) passed in onchange event handler method will provide details about checkbox element.

Thanks