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
Pooja NekkalapudiPooja Nekkalapudi 

lightning component: update a record on click of button

I would like to update a check box to true when a button is pressed on a custom object, how do I do this using lightning component
Will add more records to update later, Any help is apreciated as i am ne to lightning
Ajay K DubediAjay K Dubedi
Hi Pooja,
Follow some given steps:

<aura:component controller="updateCheckBoxPlan">
    <aura:attribute name="updateCheckBox" type="Plan__c" default="{'sobjectType':'Plan__c'}"/>
	<lightning:button variant="brand" label="Update A Check Box As True" onclick="{!c.updateCheck11}"  />


	updateCheck11 : function(c, e, h) {


	updateCheck11_helper : function(c,e,h) {
		var save_action = c.get("c.updateCheck");


public class updateCheckBoxPlan {
	public static void updateCheck(){
        list<Plan__c> Pl_list = new list<Plan__c>();
        pl_list = [select id,Valid__c from Plan__c Limit 1];
        Plan__c p =new Plan__c();[0].id;
        update p;
I hope it will help you!!
If this answers your query please mark this question as a solved so that it can be filtered out from unsolved questions.

Pratima Shrivastav 3Pratima Shrivastav 3
Hi Pooja,
I had a similar scenario. I posted here on how to create a component for this scenario.
The new LearnerThe new Learner
Hi Ajay,

I have added ur code , i am nto sure how to add to the pagealyout can you help me