We have issue with one of the apex class which stopping us from configuring a record through lightning component. When we debugged the issue we found this error in debug logs and could not identify what is the issue related to.
Class:
public with sharing class customLookUpController {
@AuraEnabled
public static List <sObject> fetchLookUpValues(String searchKeyWord, String objectName, String queryFilterField, String fieldsToQuery) {
String searchKey = searchKeyWord + '%';
fieldsToQuery = fieldsToQuery != '' ? ', '+fieldsToQuery : fieldsToQuery;
String sQuery = 'SELECT id, Name'+fieldsToQuery+' FROM '+objectName+' WHERE Name LIKE \''+searchKey+'\' '+queryFilterField+' ORDER BY createdDate DESC LIMIT 5';
List<sObject> returnList = new List<sObject>();
for (sObject obj : Database.query(sQuery)) returnList.add(obj);
return returnList;
}
@AuraEnabled
public static List <sObject> fetchLookUpValues(String searchKeyWord, String objectName, String queryFilterField) {
String searchKey = searchKeyWord + '%';
String sQuery = 'SELECT id, Name FROM '+objectName+' WHERE Name LIKE \''+searchKey+'\' '+queryFilterField+' ORDER BY createdDate DESC LIMIT 5';
List<sObject> returnList = new List<sObject>();
for (sObject obj : Database.query(sQuery)) returnList.add(obj);
return returnList;
}
@AuraEnabled
public static List <sObject> fetchLookUpValuesNew(String searchKeyWord, String objectName, String queryFilterField, String fields, String queryConditions) {
String searchKey = searchKeyWord + '%';
String sQuery;
//String allfields = '';
if(queryConditions != null && queryConditions != ''){
sQuery = 'SELECT '+fields+' FROM '+objectName+' WHERE '+queryFilterField+' LIKE \''+searchKey+'\' '+' AND '+ queryConditions +' ORDER BY createdDate DESC LIMIT 10';
System.debug('sQuery--'+sQuery);
}
else{
sQuery = 'SELECT '+fields+' FROM '+objectName+' WHERE '+queryFilterField+' LIKE \''+searchKey+'\' '+' ORDER BY createdDate DESC LIMIT 10';
System.debug('sQuery--'+sQuery);
}
List<sObject> returnList = new List<sObject>();
for (sObject obj : Database.query(sQuery)) returnList.add(obj);
return returnList;
}
}
Error:
Class.customLookUpController.fetchLookUpValues: line 10, column 1 08:11:59.0 (2330323)|FATAL_ERROR|System.QueryException: expecting a colon, found ')'
Debug log:
51.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,NONE;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
08:11:59.0 (163644)|USER_INFO|[EXTERNAL]|0052p000009sYJY|[email protected]|(GMT+01:00) Central European Standard Time (Europe/Paris)|GMT+01:00
08:11:59.0 (211455)|EXECUTION_STARTED
08:11:59.0 (217359)|CODE_UNIT_STARTED|[EXTERNAL]|apex://customLookUpController/ACTION$fetchLookUpValues
08:11:59.0 (1287969)|CODE_UNIT_STARTED|[EXTERNAL]|01p57000001MmYo|customLookUpController.fetchLookUpValues(String, String, String, String)
08:11:59.0 (2176405)|EXCEPTION_THROWN|[10]|System.QueryException: expecting a colon, found ')'
08:11:59.0 (2316403)|FATAL_ERROR|System.QueryException: expecting a colon, found ')'
Class.customLookUpController.fetchLookUpValues: line 10, column 1
08:11:59.0 (2330323)|FATAL_ERROR|System.QueryException: expecting a colon, found ')'
Class.customLookUpController.fetchLookUpValues: line 10, column 1
08:11:59.2 (2340395)|CUMULATIVE_LIMIT_USAGE
08:11:59.2 (2340395)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of Publish Immediate DML: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
08:11:59.2 (2340395)|CUMULATIVE_LIMIT_USAGE_END
08:11:59.0 (2370892)|CODE_UNIT_FINISHED|customLookUpController.fetchLookUpValues(String, String, String, String)
08:11:59.0 (2533470)|CODE_UNIT_FINISHED|apex://customLookUpController/ACTION$fetchLookUpValues
08:11:59.0 (2542518)|EXECUTION_FINISHED