function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew Aldis 15Andrew Aldis 15 

Lightning Controller cannot find my method

I have a ightning component that needs to get a string from a class, but everytime open it I get a error "Uncaught Unknown controller action 'getTableauUrl'Callback failed: aura://ComponentController/ACTION$getComponent"  Why can't it find the method.

Compoenent

<aura:component controller="TableauSalesAnalysisLightningController" implements="force:appHostable" >

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
        <aura:attribute name="tableauUrl" type="string" />
        <div style="overflow:hidden; padding:4px; border: solid #ddd 2px; border-radius:4px;" >
           <iframe id="reportFrame" src="{!tableauUrl}" height="600PX" width="100%" scrolling="no" frameborder="0" style="position:relative;"/>
          </div>
</aura:component>

Controller:
({
    doInit : function(component, event, helper) {
      console.log('doInit called ');
      var action = component.get('c.getTableauUrl');
      console.log('action called '+action);

    
    }
})
Class  (I removed the logic for security)

public with sharing class TableauSalesAnalysisLightningController {
        public String tableauUrl;
            private User user;
            private Profile profile;
            private UserRole role;
            public String divisionId;
            public String regionId;
            public String userName;
            public String channel;
            public String allParam;
            public String dcio;


    // Load the tableau username into a static at page load since this won't change
@AuraEnabled
    public string getTableauUrl() {
      
            return tableauUrl;

    }


}
 
Best Answer chosen by Andrew Aldis 15
Raj VakatiRaj Vakati
Its should be like this  .@AuraEnabled methods must be static 
 
@AuraEnabled
    public static string getTableauUrl() {
      
            return tableauUrl;

    }

 

All Answers

Raj VakatiRaj Vakati
Its should be like this  .@AuraEnabled methods must be static 
 
@AuraEnabled
    public static string getTableauUrl() {
      
            return tableauUrl;

    }

 
This was selected as the best answer
Tanuj TyagiTanuj Tyagi
Try to put Correct syntax too for js controller method. Callback code is missing