import { LightningElement, api, wire, track } from 'lwc';
import getAccDetails from '@salesforce/apex/UI_Controller.getAccountName';
export default class AccordionComp extends LightningElement {
@wire(getAccDetails, { accId: 'Account_Details', parent: '$recordId' }) accDetails(result) {

        if (result.data) {
            console.log('Check output');
        console.log('before callout');


public with sharing class UI_Controller {
@AuraEnabled (Cacheable = true)
    public static String getAccountName(String accId,String parent) {
        return 'Hello World';

  • 3
    Hi, and welcome to SFSE! Please take a moment read about How to Ask, then edit your question to include any additional relevant information. As it is, we don't know what the problem is, and there's no immediately obvious reason why it wouldn't work. Do you get any errors? Did you check debug logs? Is there any additional information we can use to help you?
    – sfdcfox
    Aug 3, 2019 at 0:19
  • I have a few thoughts- but first could you provide some more details? Are any of your log statements printing anything (apex or javascript), are you getting any error messages, how is this Lwc being used, etc. Let's start there and then I can help you troubleshoot with more context
    – Sam Howle
    Aug 3, 2019 at 1:59
  • Not sure what you’re use case is, but you haven’t even defined a “recordId” property in your code. Aug 3, 2019 at 6:13

1 Answer 1


Behaviour of wired function:

  1. It will run for the first time to register wired method where you will get result {data: undefined, error: undefined}

  2. Next time onwards, wired function will execute and invoke apex method ONLY when none of the parameters are undefined.

  3. If wired function is dependent on dynamic property like $recordId, then it will execute and invoke apex method only when dynamic property changes and not undefined.

In your case its not invoking because recordId is undefined and you are never changing it.

For testing this, you can implement below connectedCallback:

connectedCallback() {
    this.recordId = undefined; // will NOT run since undefined
    setTimeout(() => (this.recordId = 'some id'), 1000); // will run
    setTimeout(() => (this.recordId = 'some other id'), 2000); // will run
    setTimeout(() => (this.recordId = 'some other id'), 3000); // will NOT run since no change in recordId
    setTimeout(() => (this.recordId = undefined), 4000); // will NOT run since undefined although changed
    setTimeout(() => (this.recordId = null), 5000); // will run for null
    setTimeout(() => (this.recordId = 'undefined'), 6000); // will run 

Given in the comments above when it will execute and not execute.

NOTE: $ dynamic property is automatically declared. No need of separate declaration in class.

  • None of this would work.... the OP doesn’t have a variable defined for this. Aug 3, 2019 at 6:14
  • @SebastianKessel. Not really needed. $ makes it dynamic (and automatically declared/defined) - on which wire will be dependent. If you also define it as track, it makes it reactive. Both are not interdependent. For detailed explanation, you can check this: salesforce.stackexchange.com/questions/260135/….... Detailed explanation - salesforcesas.home.blog/2019/07/23/… Aug 3, 2019 at 6:40
  • RecordId was the issue and it's working, It was a small mistake from my side, trying to execute it in Ltng App rather than on the corresponding record page. Thanks for the detailed explanation @salesforce-sas
    – Ram P
    Aug 3, 2019 at 17:15
  • @RamP its actually not a mistake. I think you got confused as it always runs 1st time when registering giving undefined. Aug 3, 2019 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .