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
Leonardo MacedoLeonardo Macedo 

How can I mark a checkbox true/false with a js custom button.

I want to mark a checkbox with true or false status with an js custom button. How can I do this?
Thanks.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post i hope that will help you
1) http://amitsalesforce.blogspot.in/2016/03/wrapper-class-in-salesforce-select-all.html
 
<script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
Let us know if this will help you

Thanks
Amit Chaudhary
 
Naresh YadavNaresh Yadav
Hi Leonardo Macedo,

If you are using detail page button which executes some java script then the below code snippet will help you out.
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} 

function updateField(){ 
/*Updating field*/ 
var strQuery = "SELECT Id, Active__c FROM Account"; 

var queryResult = sforce.connection.query(strQuery); 
var records = queryResult.getArray("records"); 

var newRecords = []; 

for (var i = 0; i < records.length; i++) { 
var updateAccount = new sforce.SObject("Account"); 
updateAccount.Id = records[i].Id; 

updateAccount.Active__c = "Yes"; 
newRecords.push(updateAccount); 

} 

result = sforce.connection.update(newRecords);

Mark it as sloved if it will slove you problem.