New to apex to please bear with me. I'm using database.query for a SOQL statement from a Custom Setting. I'm then trying to retrieve data from that Custom Setting, but it seems everything is an sObject[]. In the scenario below, SearchFields__c is a single String (e.g. Name), but it won't let me assign it to a String. Any help would be appreciated. Thanks in advance.
Sample Code
public YAHS_PRT_Table_Component__c tableComponent {get;set;}
public String searchField { get; set; }
public List<String> Buttons { get; set; }
public GenericPaginationComponentContrl(){
tableComponent = [SELECT Name, IsActionColumnEnabled__c, SearchFields__c, SOQLQuery__c,
ActionButtons__c, Fields__c FROM YAHS_PRT_Table_Component__c WHERE Name = :recordName]; // Works
sObjLst = database.query(tableComponent.SOQLQuery__c); // Works
searchField = database.query(tableComponent.SearchFields__c); // Illegal assignment from List<SObject> to String
Buttons = database.query(tableComponent.ActionButtons__c.split(',')); // Doesn't work either
}
Best Answer
Your OP is somewhat unclear, but if the types are correct, then you simply need to pull the data from the fields, with no need for any additional queries.