I am trying to understand how I can handle response from the Apex Class in to the lightning component Controller. The Apex Class is like below where I am trying to check the Account Id of the Case and show a toast through lightning component

public class updateCaseRecord {    
    public static String passCase(String caseId){
        List<Case> case_recs = [SELECT id,AccountId,Status,Subject from Case WHERE Id = :caseId];
        String returnString;
        for (Case rec : case_recs)
            if (rec.AccountId == '001U000001OgQ0OIAV')
                returnString = 'Assign an actual account to the case.';
        //update case_recs;      
        return returnString;

My lightning component is like below

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"  controller="updateCaseRecord">
    <aura:attribute name="updateCase" type="Case" default="{'sobjectType':'Case'}"/>
    <lightning:button variant="brand" label="Pass To CS" onclick="{!c.passCaseToCS}"  />

Lightning Controller

   passCaseToCS : function(c, e, h) {


passCaseToCS_helper: function(c,e,h) {
    var set_action = c.get("c.passCase");
    set_action.setParams({caseId: c.get('v.recordId')});
    set_action.setCallback(this, result => {
        type: 'error',
        message: result.returnString,
        mode: 'pester'

But here I am getting error like Failed to save UpdateCaseCompHelper.js: ESLINT_ERROR: {c:UpdateCaseComp - HELPER} line:col [68:7] --> Parsing error: Unexpected token fire : Source


You missed a period to access the function.

  • Thanks. It did fix the error but I cannot the toast to be displayed am I missing something here
    – user81642
    Apr 7 '20 at 20:32
  • @user81642 I don't know. Everything appears to be in order. Are you using this component in a Lightning App? If so, you can't use toast notifications, as they only work in Lightning.
    – sfdcfox
    Apr 7 '20 at 22:45

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.