1

I create list button OnClick Javascript Button on Lead. it will update the Is_Picked__c checkbox on selected record whenever i click the list button. but i still get MALFORMED_QUERY. Any thoughts?

{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Lead)}; 
var leadCheck = sforce.connection.query("SELECT Id, Is_Picked__c,Last_Seen_By__c FROM Lead WHERE Id ="+records[0]+" LIMIT 1");
var records1 = leadCheck.getArray("records");
var lead = records1[0];
var newRecords = [];
if (records[0] == null) { // if they dont pick any lead
alert("Please select at least one row") 
}
else if(records.length>1) { //if they pick more then 1 lead
alert("You only can pick one lead") ;
}
else if(lead.Is_Picked__c){
alert("This lead already picked by "+lead.Last_Seen_By__c);
}
else{
for (var n=0; n<records.length; n++) 
{ 
        var c = new sforce.SObject("Lead");
        c.id = records[n]; c.Is_Picked__c = 'true';
        newRecords.push(c); 
} 
result = sforce.connection.update(newRecords);
window.open('/'+records[0]);
}
3

update your query : sforce.connection.query("SELECT Id, Is_Picked__c,Last_Seen_By__c FROM Lead WHERE Id =\'"+records[0]+"\' LIMIT 1");

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.