I need to put an if condition on which if the wire is returning an empty : can anyone help me out for this

wire(tryfh, { chadhad: '$chadhad' }) sdfsdfsdf(result) {

        // Hold on to the wired result value so we can refresh it later
        this.hsdfhsjfhsjf = result;


how to check if result is empty

  • 1
    Hi, and welcome to SFSE! Can you please be a bit more specific? What do you mean by "empty"? An empty list? A null value? A map with no fields? – sfdcfox May 15 '20 at 14:13
  • If(result.data.length){ } – Rijwandeltax May 15 '20 at 14:30

I had this issue today, the way to check this is with a getter method on the component

get hasDuplicates(){
    if(this.dupLeads && this.dupLeads.length){
        return true;
    return false;

Make sure to check for BOTH the variable and then the variable length (as I'm doing in my if statement). This is because the getter is apparently called multiple times while the page is being loaded, and the first few times, the wired variable will be undefined, which will cause an error if you try to access the .length property.

So first you check if it's defined, and if so, check if it has a length property. If it has then it means that the wire service returned some data (as opposed to an empty "data" object).

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.