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  RussoAndrew 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
<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/

 
Andrew  RussoAndrew Russo
any ideas?
 
mukesh guptamukesh gupta
Hi Andrew,

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

 
Andrew  RussoAndrew Russo
just opened an incognito window and navigated here and got this.
User-added image​​​​​​​
Christoph Lieske 7Christoph Lieske 7
I just saved the Helper Class within the Application and that solved the issue in my case.

So for me it seems, that this is a compilation issue.
Andrew  RussoAndrew Russo
That was the issue I had too. Forgot to update the question with the solution from the salesforce developer support team.