Getting this annoying error when trying to save my code. I've been doing some and research and people have suggested deleting and rewriting but that doesn't seem to work either.
Any suggestions would be great and I'm going mad!
public class ContactSearchController {
private String soql {get;set;}
public LIST<Contact> contacts {get;set;}
public String sortDir {
get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; }
set;
}
public String sortField {
get { if (sortField == null) {sortField = 'lastName'; } return sortField; }
set;
}
public String debugSoql {
get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
set;
}
public ContactSearchController() {
soql = 'select firstName, lastName, account.name, TUQ_Score__c, Pulse_Category__c, Date_of_Last_Pulse_Score_1__c, How_could_we_get_you_to_a_10_TUQ__c from contact where account.name != null';
runQuery();
}
public void toggleSort() {
sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
runQuery();
}
public void runQuery() {
try {
contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
}
}
public PageReference runSearch() {
String firstName = Apexpages.currentPage().getParameters().get('firstName');
String lastName = Apexpages.currentPage().getParameters().get('lastName');
String accountName = Apexpages.currentPage().getParameters().get('accountName');
String TUQScore = Apexpages.currentPage().getParameters().get('TUQ_Score__c');
String PulseCategory = Apexpages.currentPage().getParameters().get('Pulse_Category__c');
String DateofLastPulseScore = Apexpages.currentPage().getParameters().get('Date_of_Last_Pulse_Score_1__c');
String Howcouldwegetyoutoa10 = Apexpages.currentPage().getParameters().get('How_could_we_get_you_to_a_10_TUQ__c');
soql = 'select firstName, lastName, account.name, TUQ_Score__c, Pulse_Category__c, Date_of_Last_Pulse_Score_1__c, How_could_we_get_you_to_a_10_TUQ__c from contact where account.name != null';
if (!firstName.equals(''))
soql += ' and firstName LIKE ''+String.escapeSingleQuotes(firstName)+'%'';
if (!lastName.equals(''))
soql += ' and lastName LIKE ''+String.escapeSingleQuotes(lastName)+ '%'';
if (!accountName.equals(''))
soql += ' and account.name LIKE ''+String.escapeSingleQuotes(accountName)+ '%'';
if (!PulseCategory.equals(''))
soql += ' and Pulse_Category__c includes (''+Pulse+'')';
renQuery();
return nill;
}
public List<String> PulseCategory {
get {
if (PulseCategory == null) {
PulseCategory = new List<String>();
Schema.DescribeFieldResult field = Contact.Pulse_Category__c.getDescribe();
for (Schema.PicklistEntry f : field.getPicklistValues())
PulseCategory.add(f.getLabel());
}
return PulseCategory;
}
set;
}
}
equals('')
Instead use aString.isNotBlank(yourVariable)
method of the String class.