• Christoph Lieske 7
  • NEWBIE
  • 15 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
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/

 
Get Started with the Salesforce Platform: While Install the DreamHouse App, Initialize Sample Data is not ended. I have tried two Create a Trailhead Playground. But it same result. not eneded. Any help?