+ Start a Discussion
CosCCosC 

Jquery in Visualforce page with where Clause is not working

Jquery in visualforce page without where clause is working fine. But when i add a where clause to select closed Case's is not working.

Code that Call getall cases:

            var Case = new SObjectData();
            Case.errorHandler = displayError;
              $j(document).ready(function() {
                regBtnClickHandlers();
                getAllCase('Closed');
            });


Below is my code for Jquery:
 
            function getAllCase(sreas) {
                
Case.fetch('soql','SELECT Id, AccountId, CaseNumber, OwnerId, Reason, Status, Subject, Description, ContactId, Priority, Origin from Case WHERE Status = '+sreas+' Order by CaseNumber asc ',function() {
                    showCase(Case.data());
                });
            }

Please let me know what is wrong in this query

SScholtzSScholtz
I think you've got a typo above, you need to surround your "sreas" in quotes,

As it is now, your query looks like:
SELECT Id, AccountId, CaseNumber, OwnerId, Reason, Status, Subject, Description, ContactId, Priority, Origin from Case WHERE Status = Closed Order by CaseNumber asc

Pretty sure it needs to be this, with the 'Closed' wrapped in quotes:
SELECT Id, AccountId, CaseNumber, OwnerId, Reason, Status, Subject, Description, ContactId, Priority, Origin from Case WHERE Status = 'Closed' Order by CaseNumber asc



So your final code probably needs to be this:
Case.fetch('soql','SELECT Id, AccountId, CaseNumber, OwnerId, Reason, Status, Subject, Description, ContactId, Priority, Origin from Case WHERE Status = \''+sreas+'\' Order by CaseNumber asc ',function() {



CosCCosC
Thank you very much it works. But i get another issue now. I need to show only the case for current user so i used below query & it does not work.

 var sreas = UserInfo.getUserID();

SELECT Id, AccountId, CaseNumber, OwnerId, Reason, Status, Subject, Description, ContactId, Priority, Origin from Case WHERE OwnerId = \''+sreas+'\' Order by CaseNumber asc
CosCCosC
Issue resolved