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
Matt Brown 71Matt Brown 71 

Pass "extra" data with case creation.

I've been tasked with adding a "Create Ticket from Chat Transcript" feature.  My org no longer wants automatic case creation from prechat survey, we only want it to be done manually, via a button - no big deal.

Here is the issue, I've created a simple lightning component that displays a button on the LiveChatTranscript record page.  When the agent clicks the button: this code is executed:
 
// Show Create Ticket Page Layout For LiveChatCase Type.
var createTicketEvent = $A.get("e.force:createRecord");
createTicketEvent.setParams({
    "entityApiName": "Case",
    "recordTypeId" : recordType,
    "defaultFieldValues": {
        "Priority" : "Normal",
        "Status": "New",
        "Origin": "LiveChat",
        "Authentication_Status__c": transcript.Authentication_Status__c,
        "Description": transcript.Body,
        "AccountId": transcript.AccountId,
        "ContactId": transcript.ContactId,
        "LeadId": transcript.LeadId,
        "SuppliedEmail": transcript.Visitor_s_Email__c
    }
});

createTicketEvent.fire();

So essentially we just call the create ticket page layout and pass it some default values.  The issue is that I also want the relationship from LiveChatTranscript to Case to be made - but the relationship is a lookup field on the transcript.  Obviously I don't have the Case ID yet as the record hasn't been created.  I don't have control over the record creation since we're just calling the createTicketEvent.fire(); salesforce takes over at that point, otherwise I'd just pass the transcript Id with the data to the Apex controller.

My question, is there anyway to pass the Transcript ID through with the case creation so that I can at least, in a trigger, set the new Case ID on the relationship field for the Transcript ID given?  One solution I thought of was to create a field on the case that gets populated with the Transcript ID, then in the trigger - I take that ID, grab the transcript and set the Case relationship on the Transcript.  But this feels dirty, and a waste of a field.

For reasons - we need to keep the relationship of these 2 objects as they are.  I thought of putting the relationship on the case instead of the transcript, but that wouldn't work since a case can have multiple transcripts, and not vice versa.

Any helpful solutions would be most appreciated!