You need to sign in to do that
Don't have an account?
Brian 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 ; } }
Let me know if this fix the issue.
I updated the LIghtning component to include:
Changecaselabel.cmp ChangeCaseLabelController.js
ChangeCaseLabelHelper.js
APEX Class:
ChangeCaseLabelService.apxc
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
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.