0

here is the code.

CLS file

public with sharing class estimatevsPipeline {
    @AuraEnabled
    public static  List<AggregateResult> getestimatevsPipeline() {
        return [SELECT SUM(amount_ge_og__c) sumAmount FROM Opportunity WHERE (((IsClosed != true)AND(ForecastCategoryName in ('Commit','Commit at Risk')))OR(StageName = 'Closed Won'))AND(RecordType.DeveloperName != 'Targets')AND(Type in ('Internal to GE Parent','Internal to BHGE','External'))AND(forecast_pipeline_exception_ge_og__c != true)AND(CloseDate = THIS_QUARTER)AND(Id in (SELECT OpportunityId FROM OpportunityTeamMember WHERE (((UserId in ('0051H000009S5D2QAK','00512000007jB49AAE','0051H00000Aw9VbQAJ'))OR(UserId = '0051H00000AwEezQAF'))AND(TeamMemberRole != 'Following'))))];
    }
}

JS file

import { LightningElement, track, api, wire } from 'lwc';
import getestimatevsPipeline from '@salesforce/apex/estimatevsPipeline.getestimatevsPipeline';
export default class App extends LightningElement {    
   @track a;
   @wire(getestimatevsPipeline)
   getEstInfo({ err, data }) {
       debugger;
      // a=data;   
   this.a = data;
   };
}
1

I see a couple of issues:

  1. A wire is always first invoked with an undefined error and undefined data value, so you should always have a structure like:
if (error) {
    ...
} else if (data) {
    ...
}
  1. When defining the wire's received parameters this is an object with optional "error" and "data" properties. As such you should ALWAYS use an exploded parameter specification using those same names, otherwise it won't work. Where you called it "err", you will never have this defined, and the "error" property will never appear in your function.

Since your SOQL is an aggregate query, make sure you use the received "data" in the correct way in the client code/template (something you didn't share).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.