You need to sign in to do that
Don't have an account?
Andrew Russo
Unable to find action 'init' on the controller of c:CaseCommentsRelatedList
Can someone help me try to find the issue in this code? i am getting this error: "Unable to find action 'init' on the controller of c:CaseCommentsRelatedList"
cmp
https://github.com/kamatvs/Custom-Case-Comment-Component/
cmp
<aura:component controller="CommunityCaseDisplayController" implements="force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" > <aura:attribute name="commentsdata" type="Object"/> <aura:attribute name="RLcolumns" type="List"/> <aura:handler name="init" value="{! this }" action="{! c.init }"/> <lightning:card title="Case Comments" iconName="standard:custom"> <aura:set attribute="actions"> <lightning:button label="New" onclick="{!c.displayAddComment}"/> </aura:set> <p class="slds-p-horizontal_small"> <lightning:datatable data="{! v.commentsdata }" columns="{! v.RLcolumns }" keyField="Id" hideCheckboxColumn="true" minColumnWidth="200" maxColumnWidth="1000"/> </p> </lightning:card> <!-- display popup --> <div> <c:CreateCaseCommentComponent aura:id="displayPopup" recordId="{!v.recordId}" HideMe="{!c.hidePopup}" /> </div> </aura:component>apxc
/* * @Description: APEX Server Side Controller. * Provides methods to fetch case and work with case from Community */ public class CommunityCaseDisplayController { @AuraEnabled public static List<CaseComment> getCaseComments(String caseId) { List<CaseComment> caseComments = [SELECT Id, ParentId, IsPublished, CommentBody, CreatedDate, CreatedBy.Name, LastModifiedDate, LastModifiedById FROM CaseComment where parentId=:caseId order by CreatedDate desc]; return caseComments; } @AuraEnabled public static CaseComment addCaseComment(String caseId, String commentBody) { CaseComment caseComment = new CaseComment(ParentId=caseId, CommentBody=commentBody); insert caseComment; return caseComment; } }js
//CaseCommentsRelatedListController.js ({ init: function (cmp, event, helper) { cmp.set('v.RLcolumns', [ {label: 'Comment', fieldName: 'CommentBody', type: 'text'}, {label: 'Created Date', fieldName: 'CreatedDate', type: 'date', typeAttributes: {year:'numeric', month:'numeric', day:'numeric', hour:'2-digit', minute:'2-digit'}, initialWidth:'200'}, {label: 'Created By', fieldName: 'createByName', type: 'text', initialWidth:'200'} ]); helper.getData(cmp); }, displayAddComment: function (cmp, event, helper) { var displayPopup = cmp.find("displayPopup"); var backGroundSectionId = displayPopup.find("backGroundSectionId"); $A.util.addClass(displayPopup, "slds-fade-in-open"); $A.util.removeClass(displayPopup, "slds-fade-in-hide"); $A.util.addClass(backGroundSectionId, "slds-backdrop--open"); $A.util.removeClass(backGroundSectionId, "slds-backdrop--close"); }, hidePopup: function(component,event){ var displayPopup = component.find("displayPopup"); var backGroundSectionId = displayPopup.find("backGroundSectionId"); $A.util.removeClass(displayPopup, "slds-fade-in-open"); $A.util.addClass(displayPopup, "slds-fade-in-hide"); $A.util.removeClass(backGroundSectionId, "slds-backdrop--open"); $A.util.addClass(backGroundSectionId, "slds-backdrop--close"); } })
https://github.com/kamatvs/Custom-Case-Comment-Component/
I have tried to get this issue in your code, but not found this type of issue. Can you please clear your cache and execute your code again.
If this solution is usefull for you, Please mark as a Best Answer to help others.
Regards
Mukesh
So for me it seems, that this is a compilation issue.