Why is the console.log statement returning "undefined" in the browser console?

When I call the Apex method from Anonymous Class, it returns the expected String.

import { LightningElement, wire, track } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import Id from '@salesforce/user/Id';
import getUsersPermissionSet 
  from '@salesforce/apex/EsrmHomePage_Ctrl.getUsersPermissionSet';

export default class EsrmHomePageNavigation extends NavigationMixin(LightningElement) {

  @track isManager = false;

    wiredGetUsersPermissionSet({data, error}) {
    console.log('*** data', data);

    if (data) {
      this.usersPermissionSet = data;
    if (this.usersPermissionSet) {
      if (this.usersPermissionSet.includes("Manager")){
        this.isManager = true;

public with sharing class EsrmHomePage_Ctrl {

    public static String getUsersPermissionSet(){

      String usersMainPermissionSet;
      List<PermissionSetAssignment> usersPermissionSets = 
        [SELECT PermissionSet.Label 
         FROM PermissionSetAssignment 
         WHERE PermissionSet.Label like '%Technical Assessment%' 
         AND AssigneeId = :UserInfo.getUserId()];
      /* SysAdmins may have a Basic and Manager permissionset. 
       * All other ESRM users should only have one.*/
      if(usersPermissionSets != null) {
        if(usersPermissionSets.size() > 1) {
          for(PermissionSetAssignment permSet : usersPermissionSets) {
            String permSetLabel = permSet.PermissionSet.Label;
            if(permSetLabel.contains('Manager')) {
              usersMainPermissionSet = permSetLabel;
        } else {
          String permSetLabel = usersPermissionSets.get(0).PermissionSet.Label; 
          usersMainPermissionSet = permSetLabel;
      System.debug('*** usersMainPermissionSet: ' + usersMainPermissionSet);
      return usersMainPermissionSet;

enter image description here

  • 1
    Just as FYI - similar to Caspar's answer to your previous question, you really should handle/use the error returned by these calls - it would've told you the issue in this scenario. Sep 13, 2021 at 20:27

1 Answer 1


For you to be able to use methods as wired, the Auraenabled method needs to be set as cacheable=True

Auraenabled (cacheable=true)

Client-Side Caching of Apex Method Results

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.