So, I'm getting the values of the properties of a custom sObject in my org, in an Apex method. So, this is how it works, basically I receive via parameter a list of strings that are the fields that I need to fetch from the sObject. So, the process is this:
for(Item__c item : items){
for(String field : fields){
columns.add(String.valueOf(item.get(field)));
}
}
The fields are being sent from my lightning component, in a way I can directly get them via sObject.get. The thing is, there is a field that is a lookup field (its called listing_type) and I don't know how can I access a field of the listing_type object. I can't access it directly like this, so how can I achieve this? It should be listing_type__r.name, but if I pass that to the item.get() it doesn't work.