You need to sign in to do that
Don't have an account?
GÜNES Admin
How to pass custom object recordID to lightning button to perform action?
Dear everyone,
I am new to Apex/Lightning development so please use simple language in your answer :)
I have a custom object called Change.
I have a lightning button called "Cancel Change", placed in a Lightning Component (aura).
At the moment, the button is just displaying a dummy text "You clicked on me"...
The true purpose of this button is to:
- get the Change recordId (record where the button was pressed)
- update the picklist value of field "Stage" to "Canceled".
- display a success message
- do not navigate away, remain on the same Change record
So, I have the CMP file that defines the visual aspects of the Buttons:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<div align="right">
<lightning:buttonGroup>
<lightning:helptext content="Use these buttons as Workflow Actions"/>
<p><lightning:button variant="success" label="Progress Workflow" onclick="{!c.handleClick}"/></p>
<p><lightning:button variant="destructive" label="Cancel Change" onclick="{!c.handleClick}"/></p>
</lightning:buttonGroup>
</div>
</aura:component>
And there is the JS file which would normally define the behavior:
({
handleClick : function(component, event, helper) {
var selectedButtonLabel = event.getSource().get("v.label");
alert("You clicked on: " + selectedButtonLabel);
}
})
My difficulty is:
- How do I pass the recordID of the Change record to the code
- How do I update the field inside the record when Cancel is pressed?
Do I need to write an Apex container to start with?
Please provide guidance, thank you in advance!!
I am new to Apex/Lightning development so please use simple language in your answer :)
I have a custom object called Change.
I have a lightning button called "Cancel Change", placed in a Lightning Component (aura).
At the moment, the button is just displaying a dummy text "You clicked on me"...
The true purpose of this button is to:
- get the Change recordId (record where the button was pressed)
- update the picklist value of field "Stage" to "Canceled".
- display a success message
- do not navigate away, remain on the same Change record
So, I have the CMP file that defines the visual aspects of the Buttons:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<div align="right">
<lightning:buttonGroup>
<lightning:helptext content="Use these buttons as Workflow Actions"/>
<p><lightning:button variant="success" label="Progress Workflow" onclick="{!c.handleClick}"/></p>
<p><lightning:button variant="destructive" label="Cancel Change" onclick="{!c.handleClick}"/></p>
</lightning:buttonGroup>
</div>
</aura:component>
And there is the JS file which would normally define the behavior:
({
handleClick : function(component, event, helper) {
var selectedButtonLabel = event.getSource().get("v.label");
alert("You clicked on: " + selectedButtonLabel);
}
})
My difficulty is:
- How do I pass the recordID of the Change record to the code
- How do I update the field inside the record when Cancel is pressed?
Do I need to write an Apex container to start with?
Please provide guidance, thank you in advance!!