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
Brian RosenfeltBrian Rosenfelt 

Unable to find action 'doInit' on the controller of c:E2E_ChangeCaseLabel

Looking for help on this error - I'm sure a small syntax issue in my code.  Thank you!
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ChangeCaseLabel">
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <aura:handler event="force:refreshView" action="{!c.doInit}" />  
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
 
({
   init : function(component, event, helper) {
        var action = component.get("c.getCaseOrigin");
        action.setParams({ caseId: component.get("v.recordId")});
        action.setCallback(this,$A.getCallback(function(response1)
         {
         var state = response1.getState();             
         if (state === "SUCCESS")  
         {
             var result= response1.getReturnValue();
         var workspaceAPI = component.find("workspace");
         workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: result
            });
        })
        .catch(function(error) {
            console.log(error);
        });
         }
         }
        ));
        $A.enqueueAction(action);       
        
        
    }
})
 
({
	doInit : function(component, event, helper) {
		helper.init(component, event, helper);
	}
})
 
public with sharing class ChangeCaseLabel {
    public static ChangeCaseLabelService service = new ChangeCaseLabelService();
    @AuraEnabled 
    public static String getCaseOrigin(String caseId){
        return service.getCaseOrigin(caseId);
    }
    
    
}
 
public class ChangeCaseLabelService {
    
    public String getCaseOrigin(String caseId){
        Case c = [Select id ,CaseNumber , Origin from Case where Id = :caseId];
        return c.Origin+'-'+c.CaseNumber ; 
    }
}

 
Abdul KhatriAbdul Khatri
Are you getting any error message. I think first think need to be change is with the name of the controller class. Please add Controller in the end of the class like ChangeCaseLabelController, similar in the component reference
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ChangeCaseLabelController">
Let me know if this fix the issue.

 
Brian RosenfeltBrian Rosenfelt
This is the error I'm receiving:  Unable to find action 'doInit' on the controller of c:ChangeCaseLabelUser-added image

I updated the LIghtning component to include:

Changecaselabel.cmp
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ChangeCaseLabel">
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <aura:handler event="force:refreshView" action="{!c.doInit}" />  
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
ChangeCaseLabelController.js
({
    init : function(component, event, helper) {
        var action = component.get("c.getCaseOrigin");
        action.setParams({ caseId: component.get("v.recordId")});
        action.setCallback(this,$A.getCallback(function(response1)
         {
         var state = response1.getState();             
         if (state === "SUCCESS")  
         {
             var result= response1.getReturnValue();
         var workspaceAPI = component.find("workspace");
         workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: result
            });
        })
        .catch(function(error) {
            console.log(error);
        });
         }
         }
        ));
        $A.enqueueAction(action);       
        
        
    }
})

ChangeCaseLabelHelper.js
({
	doInit : function(component, event, helper) {
		helper.init(component, event, helper);
	}
})

APEX Class:
public with sharing class ChangeCaseLabel {
    public static ChangeCaseLabelService service = new ChangeCaseLabelService();
    @AuraEnabled 
    public static String getCaseOrigin(String caseId){
        return service.getCaseOrigin(caseId);
    }
    
    
}

ChangeCaseLabelService.apxc
public class ChangeCaseLabelService {
    
    public String getCaseOrigin(String caseId){
        Case c = [Select id ,CaseNumber , Origin from Case where Id = :caseId];
        return c.Origin+'-'+c.CaseNumber ; 
    }
}

 
Abdul KhatriAbdul Khatri
OK

Please swap the code of ChangeCaseLabelHelper.js and ChangeCaseLabelController.js. I mean Move the ChangeCaseLabelController.js code to ChangeCaseLabelHelper.js and ChangeCaseLabelHelper.js code to ChangeCaseLabelController.js
Brian RosenfeltBrian Rosenfelt
Tried that - same error.
Abdul KhatriAbdul Khatri
Can you share the screenshot of your controller and helper.js files?
Brian RosenfeltBrian Rosenfelt
User-added imageUser-added image
Abdul KhatriAbdul Khatri
Are you sure you are refereshing you component on the page?

It is very funky it doesn't work in the first refresh but you need to refresh multiple times and even sometimes you need to go to Edit Page. Make sure you are getting the latest and greatest code on the page.
Brian RosenfeltBrian Rosenfelt
Let me double check this morning - thanks for reviewing!
 
David Roberts 4David Roberts 4
Did Abdul's suggestion work for you? It should have: the doInit function should be in the controller.js which then calls the helper "init" function. Please mark his answer as the best as this will help others.