0

I am using the lightning datatable in order to display the CaseShare data for a Case record within a lightning component. The feature works great however as the field UserOrGroupId on the CaseShare object is not editable I can only ever get the table to return the Id value of the user or group with which the record is shared. Below I am trying to override the value with a text value. But I am stopped as the UserOrGroupId is not editable. I have also tried to create a map of the data but was unable to get the correct data to display on my datatable.

    @AuraEnabled 
    public static List<sObject> getCaseShareData(Id caseId){

    List<sObject> caseShareList = [Select Id, CaseId, RowCause, UserOrGroupId from CaseShare where CaseId = :caseId];

    for(sObject myCaseShare : caseShareList){

        myCaseShare.put(CaseShare.UserOrGroupId, 'Test Name');
    }


    return caseShareList;

}
1

This is a good place to use a wrapper object, a simple Apex class that embeds the sObject you're returning (here, a CaseShare) along with any extra data points you want to include that aren't part of the sObject itself. It could look like this:

public class CaseShareWrapper {
    @AuraEnabled 
    public CaseShare share;
    @AuraEnabled
    public String displayName;
}

Then, your controller method can create and return a List<CaseShareWrapper>, setting the display name for each entity as you desire.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.