I have the following soql
@AuraEnabled(cacheable=true)
public static List<AggregatedResult__c> getTarget() {
Id currentUserId = UserInfo.getUserId();
String query = 'SELECT ';
for(Schema.FieldSetMember f : SObjectType.AggregatedResult__c.FieldSets.Dashboard_Fields.getFields()) {
query += f.getFieldPath() + ', ';
}
query += 'Name, User__c, (Select id, Main_Target__c from Targets__r) FROM AggregatedResult__c where User__c =:currentUserId' ;
List<AggregatedResult__c> aggr = Database.query(query);
return aggr;
}
How do I get the value for Main_Target__c in Javascript.
I tried the following but isnt working
@wire(getTarget)
dataRecord({data, error}){
if(data){
for (let i of data[0].Targets__r) {
this.targetEvt = data[0].Targets__r.Main_Target__c
console.log("targetEvt1: ",targetEvt);
}
}