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
satheesh psatheesh p 

Invalid literal value [1, 1]: 'edit': Source

i am using below code.
editReord.cmp

<aura:component> 
    <ui:button label="Edit Record" press="{!c.edit}"/> 
</aura:component>

editRecordController.js
edit: function(component, event, helper) 
{
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({ "recordId": component.get("v.contact.Id") }); 
    editRecordEvent.fire(); 
}

when i am try to save controller it shows Invalid literal value [1, 1]: 'edit': Source.
what's error in the above code.
 
Best Answer chosen by satheesh p
sfdcMonkey.comsfdcMonkey.com
hi Sateesh
you got this error because 
controller and helper javaScript code always wrap in parentheses and curly braces like  ({....code here })

wrap your code inside it 
({
    edit: function(component, event, helper) {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({ "recordId": component.get("v.contact.Id") }); 
    editRecordEvent.fire(); 
    }
})

and save it 
if it helps you mark it best answer so it make proper solution for others 
Thanks 

All Answers

Veera7Veera7
Hi Sateesh,

the below code should solve your issue
 
({
    edit: function(component, event, helper) 
    {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({ "recordId": component.get("v.contact.Id") }); 
    editRecordEvent.fire(); 
    }
})

 
sfdcMonkey.comsfdcMonkey.com
hi Sateesh
you got this error because 
controller and helper javaScript code always wrap in parentheses and curly braces like  ({....code here })

wrap your code inside it 
({
    edit: function(component, event, helper) {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({ "recordId": component.get("v.contact.Id") }); 
    editRecordEvent.fire(); 
    }
})

and save it 
if it helps you mark it best answer so it make proper solution for others 
Thanks 
This was selected as the best answer
suneel varmasuneel varma
hi veera7,
THANKS!!

Am also facing same type of issue..thanks for providing the solution.might be its a best answer