July 4, 2020

We can't load this chat, because something went wrong - Salesforce Chat Issue

1. Check the OWD on Chat Transcript Object.
If it is set to private, then you cannot view the Chat Transcript unless you are the owner or it is shared with you(Manual Sharing, Role Hierarchy, Sharing Rules, etc.)

2. Inspect in your browser.
a. Right Click on your browser and select Inspect.
b. Click Console tabs.
c. Check whether any custom Lightning components added are throwing any exceptions. In this case, remove the custom components added and try to view.

3. Query Body from Chat Transcript (LiveChatTranscript) object to check whether it is blank or null.

SELECT Body FROM LiveChatTranscript WHERE Id = '<Id of the Chat Transcript Record>'

July 2, 2020

lightning:recordEditForm getting Record Id after insert

Sample Code:

Component:

<aura:component implements="force:lightningQuickAction,force:hasRecordId" controller="NewCaseController">
   
    <lightning:recordEditForm objectApiName="Case" onsuccess="{!c.handleSuccess}" aura:id="myRecordForm">
        <lightning:messages />
        <lightning:inputField aura:id="field" fieldName="Subject" />
        <lightning:inputField aura:id="field" fieldName="Origin" />
        <lightning:inputField aura:id="field" fieldName="Reason" />
       
        <div class="slds-m-top_medium">
            <lightning:button type="submit" label="Save Record"/>
        </div>
    </lightning:recordEditForm>
   
</aura:component>

JavaScript Controller:

({
   
    handleSuccess: function(component, event, helper) {
       
        var payload = event.getParams().response;
        console.log( 'RecordId is ' + payload.id );
        var action = component.get( "c.updateTranscript" );
        action.setParams({
            recordId: component.get( "v.recordId" ),
            caseId: payload.id
        });
        action.setCallback( this, function( response ) {
            var state = response.getState();
            if ( state === "SUCCESS" ) {
               
                $A.get('e.force:refreshView').fire();
                $A.get("e.force:closeQuickAction").fire();
               
            }
        });
        $A.enqueueAction(action);
       
    }
   
})


Apex Controller:

public class NewCaseController {
   
    @AuraEnabled
    public static void updateTranscript( Id recordId, Id caseId ) {
       
        system.debug( 'Transcript Id is ' + recordId + ' and Case Id is ' + caseId );
        update new Case_Transcript__c( Id = recordId, Case__c = caseId );
       
    }

}

Output: