You need to sign in to do that
Don't have an account?
Naofumi Kun
Lightning component: Make a checkbox True upon clicking the button
I created a Lightning Component that will update the value of the field "Submit Go-No Go Question?" from the Opportunity Object.
I created the following:
Apex Class - updateCheckBoxPlan
=================================
public class updateCheckBoxPlan {
@AuraEnabled
public static void updateCheck(){
list Pl_list = new list();
pl_list = [select id,Opportunity.Submit_Go_No_Go_Question__c from Opportunity Limit 1];
Opportunity p =new Opportunity();
p.id=pl_list[0].id;
p.Opportunity.Submit_Go_No_Go_Question__c=true;
update p;
}
}
=================================
Component - Submit
=================================
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" controller="updateCheckBoxPlan">
<aura:attribute name="updateCheckBox" type="Opportunity" default="{'sobjectType':'Opportunity'}"/>
<lightning:button variant="brand" label="Confirm" onclick="{!c.updateCheck11}" />
</aura:component>
=================================
Controller - SubmitGNGController
=================================
({
updateCheck11 : function(c, e, h) {
h.updateCheck11_helper(c,e,h);
},
})
=================================
Helper - SubmitGNGHelper
=================================
({
updateCheck11_helper : function(c,e,h) {
alert('Success!');
var save_action = c.get("c.updateCheck");
save_action.setParams({
});
$A.enqueueAction(save_action);
}
})
=================================
Any help is much appreciated!
I created the following:
Apex Class - updateCheckBoxPlan
=================================
public class updateCheckBoxPlan {
@AuraEnabled
public static void updateCheck(){
list Pl_list = new list();
pl_list = [select id,Opportunity.Submit_Go_No_Go_Question__c from Opportunity Limit 1];
Opportunity p =new Opportunity();
p.id=pl_list[0].id;
p.Opportunity.Submit_Go_No_Go_Question__c=true;
update p;
}
}
=================================
Component - Submit
=================================
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" controller="updateCheckBoxPlan">
<aura:attribute name="updateCheckBox" type="Opportunity" default="{'sobjectType':'Opportunity'}"/>
<lightning:button variant="brand" label="Confirm" onclick="{!c.updateCheck11}" />
</aura:component>
=================================
Controller - SubmitGNGController
=================================
({
updateCheck11 : function(c, e, h) {
h.updateCheck11_helper(c,e,h);
},
})
=================================
Helper - SubmitGNGHelper
=================================
({
updateCheck11_helper : function(c,e,h) {
alert('Success!');
var save_action = c.get("c.updateCheck");
save_action.setParams({
});
$A.enqueueAction(save_action);
}
})
=================================
Any help is much appreciated!
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Apex:
Component:
Controller:
Place this component on record detail page using Lightning App Builder.
I hope it helps you.
Kindly 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. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Apex:
Component:
Controller:
Place this component on record detail page using Lightning App Builder.
I hope it helps you.
Kindly 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. It will help to keep this community clean.
Thanks and Regards,
Khan Anas