1

i Want to execute a query in javascript , the query works but when i want to add a where clause to filter the records , it returns noting here is my code:

  function queryAndUpdateLead(obj,obj1) { 
                var a = $(obj).closest('tr').after('<p>This should work</p>');    
                alert(obj1);    
                var soql;
                 var result;
                 var records;
                   var record ='' ;
//here is the problem
                soql = "select id,name,Duree__c,Poste__c,Suivi_client__c,Domaine__c,Responsable_compte__c,Interlocuteur_Client__c,Email_interlocuteur__c,Coefficient__c,Salaire__c,Taches_remplir__c,Nombre_de_postes__c,Annonce__c,Type_de_prestation__c,Qualification__c from placement__c where id = obj1";
                result = sforce.connection.query(soql);
                records = result.getArray("records");
                alert(records.length);
                for (var i=0; i< records.length; i++) {
                 record = record + records[i];
                }
    document.getElementById("myTable").style.visibility = "visible";
            }

Note: when i execute the query without the where clause , it works and it returns 204 records.

1 Answer 1

4

The way you have written it will search for rows with an where id = "obj1", which is not what you want.

Try

 soql = "select id,name,Duree__c,Poste__c,Suivi_client__c,Domaine__c,Responsable_compte__c,Interlocuteur_Client__c,Email_interlocuteur__c,Coefficient__c,Salaire__c,Taches_remplir__c,Nombre_de_postes__c,Annonce__c,Type_de_prestation__c,Qualification__c from placement__c where id = '" + obj1 + "'";
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .