0

I get this error message. Not sure why. Im not missing any semicolons

Error : Parse error. 'identifier' expected newLeadClick : function(component, event, helper) {

    newLeadClick : function(component, event, helper) {
        const workspaceAPI = component.find("workspace");
            workspaceAPI.getEnclosingTabId().then(function(tabId) {
                const tabContext = {
                    parentTabId: tabId,
                        url: '/lightning/r/Lead/'+component.get("v.LeadId")+'/view',
                            focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
    },
 /**
  *This function is responsible for opening the opportunity page in subtab in readmode on click of Open Opportunity Button
  */
    newOppClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Opportunity/'+component.get("v.OppId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
   },

3 Answers3

0

here is the entire code

({
    doInit : function(component, event, helper) {
        helper.getLeadId(component);
    },
    /**
     *This function is responsible for opening the lead page in read mode on click of Open Lead button
     */
    newLeadClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Lead/'+component.get("v.LeadId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
    },
 /**
  *This function is responsible for opening the opportunity page in subtab in readmode on click of Open Opportunity Button
  */
    newOppClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Opportunity/'+component.get("v.OppId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
   },
     afterSaveOpp : function(component, event, helper) {
        component.set("v.showRecord", true);
    },
    /**
     * this function is responsible for creating a default lead and attach it to transcript,
     * and then open the same lead inside a lightning component in a new sub tab for user
     * to add/modify the fields and save
     */
    afterSaveLead : function(component, event, helper) {
        component.set("v.editmode", true);
        const action = component.get("c.attachToTranscript"); 
        action.setParams({ leadId : null, chatTranscriptId: component.get("v.recordId")});
        action.setCallback(this, function(response) {
            const state = response.getState();
            const result = response.getReturnValue();
            if (state === "SUCCESS"){
                component.set("v.LeadId", result);
                component.set("v.showRecord", false);
                const workspaceAPI = component.find("workspace");
            workspaceAPI.getEnclosingTabId().then(function(tabId) {
                    const tabContext = {
                        parentTabId: tabId,
                        pageReference: {
                            "type": "standard__component",
                            "attributes": {
                                "componentName": "c__ShowLeadEditMode"  // c__<comp Name>
                            },
                            "state": {
                                "c__leadid": component.get("v.LeadId") // c__<comp attribute Name>
                            }
                        },
                        focus: true
                    }
                    helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
                });
                
            } else {
                 helper.showToast(component);
            }
            component.set("v.showSpinner", false);
        });
        $A.enqueueAction(action);
         },
});
0

The cause of this type of error is usually a misplaced comma in an object or array definition:

var obj = {
  id: 40,
  name: "objectTest",  <--
}

It looks in your code, you have an extra comma at the end where the arrow is pointing:

afterSaveLead : function(component, event, helper) {
    component.set("v.editmode", true);
    const action = component.get("c.attachToTranscript"); 
    action.setParams({ leadId : null, chatTranscriptId: component.get("v.recordId")});
    action.setCallback(this, function(response) {
        const state = response.getState();
        const result = response.getReturnValue();
        if (state === "SUCCESS"){
            component.set("v.LeadId", result);
            component.set("v.showRecord", false);
            const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
                const tabContext = {
                    parentTabId: tabId,
                    pageReference: {
                        "type": "standard__component",
                        "attributes": {
                            "componentName": "c__ShowLeadEditMode"  // c__<comp Name>
                        },
                        "state": {
                            "c__leadid": component.get("v.LeadId") // c__<comp attribute Name>
                        }
                    },
                    focus: true
                }
                helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
            });
            
        } else {
             helper.showToast(component);
        }
        component.set("v.showSpinner", false);
    });
    $A.enqueueAction(action);
     },        <--
});
CremBluRay
  • 12
  • 1
  • Removing comma did not fix the error. It throwing error on this line newLeadClick : function(component, event, helper) { – Shruthi R Nov 16 '20 at 03:58
  • Here is the exact error: Parse error. 'identifier' expected newLeadClick : function(component, event, helper) { – Shruthi R Nov 16 '20 at 03:59
0

I did fix some of the commas with semicolon. Now I get this error

Parameter must have JSDoc. newLeadClick : function(component, event, helper) {