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
Arun Kumar 76Arun Kumar 76 

How do I get Checkbox text if that perticular checkbox is checked?

What I want to do is, if user check Duplicate Checkbox, "Duplicate" text should saved in the local variable.
I achieved this by using user interface like formula field and Workflow field update

User-added image
     if(Duplicate__c=TRUE,'Duplicate','' )

but I think that is not optimise solution, because I have to create seprate formula field for every checkbox.

Actually I'm a .Net guy. In .net we can get the Text as checkboxId.Text. It will give the "Duplicate". But I don't know the best solution.

suppose I have 20 checkbox. If i checked 10 checkbox and click on save button those 10 texts should assigned in 10 diff local variables. So that I can pass those values to external WebService.


Thanks in advance
ShashForceShashForce
Hi Arun,

In apex, you can use "Describe" methods to get field names. Please see if this helps: https://developer.salesforce.com/forums/ForumsMain?id=906F000000090l1IAA

Thanks,
Shashank
James LoghryJames Loghry
You can solution this many ways, but below are two that you might consider:
  1. Instead of using checkboxes, maybe a selectList of would be better, with a blank / default value http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectList.htm
  2. Or use your exsiting boolean values when calling the webservice.  Next, take the boolean value and wrap it in a ternary condition. You could also invoke a separate helper method that wraps the boolean in a ternary condition and returns the resulting string of either 'Duplicate' or ''.  Take a look at the ternary operator in the following link: http://mavens.force.com/conversation/apex-shorthand