0

I want to relate Case and Account with my Chat Transcript which I am getting through an imperative apex call.

I found a way where it is mentioned-- Automatically associate chat transcript to case and account

However, this is in VF page and we need to it in LWC.

We are doing this:

    renderedCallback() {
    var btns = this.template.querySelectorAll("lightning-input");
    btns.forEach(input =>{
        if(input.value != null){
            this.btn = input.value;
        }
    })
    this.handleStartChats();
    console.log('this.btn ->'+this.btn);
    
    // Imparative Call to send PID 
    if ( this.btn != null ) {  
        console.log('Inside imparative call');
        openConsumerAccountRecord( {selectedPid: this.btn} )    
        .then(result => {  
            console.log('result chk->'+result);
            this.accRec = result;
        
            // send accountId to createCase method
            createCase( {accountId: this.accRec} )    
                .then(result => {  
                    this.caseId = result;
                    console.log('this.caseId->'+this.caseId);    
                })  
                .catch(error => {  
                    console.log('error->'+error.body.message);
                    this.error = error;    
                });
            })  
        .catch(error => {  
            console.log('error->'+error.body.message);
            this.error = error;    
        });    
    } else{
        this.accRec = undefined;
    }
}

handleStartChats(event) {
    console.log('MVK Inside handleStartChat--->');
    console.log('MVK Inside handleStartChat event--->'+event);
    console.log('MVK event--->'+JSON.stringify(event));
    this.isSpinner = !this.isSpinner;
    this.template.querySelectorAll("lightning-input").forEach(input => {
        this.fields[this.namelist.indexOf(input.name)].value = input.value;
    });

    console.log('this.fields--->'+JSON.stringify(this.fields));
    
    if (this.validateFields(this.fields).valid) {
        this.startChat(this.fields);            
    } else {
        // Error handling if fields do not pass validation.
    }
}

Your Answer

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

Browse other questions tagged or ask your own question.