Please help me how to get value for split values "valueArray[1]" in below query.
I am trying to fetch the records, but i found issue in writing dynamic query. Please let me know if I am missing syntax in belowsoql query.
List<String> valueArray = new List<String>();
for(String strValues : listOfValues) {
valueArray = strValues.split('-');
Integer intValue = Integer.ValueOf(valueArray[1]);
for(sObject sObj : Database.query('SELECT Id FROM ' + valueArray[0] + ' WHERE CreatedDate < Last_N_Days:intValue ')) {
}
valueArray
is a String in this example, you cannot access the index of a String. What doeslistOfValues
look like, something like {'Account-20', 'Contact-10'}` i.e look for Accounts created in last 20 days, look for Contacts created in last 10 days?