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
degmodegmo 

Passing record from Lightning Component

Hello,
I am working with a lightning component button that lives on a custom object record page.  When the button is clicked, I want to pass the current record to a controller class and do some processing.  I know I can pass the "recordId" and that works fine but I am trying to avoid querying the other fields of the record and attempting to pass "v.record" instead of "v.recordId" but I get a null value inside the controller.  I am trying to do something like this:  Is it possible?
 
myMethod: function(component, event, helper) {
var action = component.get("c.processRecord");
action.setParams(
{
    'curRecord' : component.get("v.record")
}
);
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")  {
     console.log("--> Data returned is: ", response.getReturnValue());
 }
else
{      
     console.log("--> Data not returned is ");             
});
        $A.enqueueAction(action);
}

 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Degmo,

Have you checked if you have implemented force:hasRecordId https://developer.salesforce.com/docs/component-library/bundle/force:hasRecordId/documentation?

Also have you checked LDS https://trailhead.salesforce.com/en/content/learn/v/modules/lightning_data_service/lightning_data_service_get_started#:~:text=LDS%20is%20the%20Lightning%20Components,data%20displayed%20on%20a%20page.&text=Lightning%20Data%20Service%20identifies%20and,that%20updates%20all%20relevant%20components.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.