You need to sign in to do that
Don't have an account?
noor Zabi
Create a lightning component which has three button --Button 2 - to display the success toast message (Which contains record id)
Components:--
<aura:component controller="Staffbutton" implements="lightning:availableForFlowActions, force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="Staffbutton" type="string"/>
<aura:attribute name="StaffdId" type="String"/>
<lightning:button label="Success" variant="brand"
onclick="{!c.displaymsg}"/>
</div>
</aura:component>
Controller:-
displaymsg: function (component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
//fire the toast event in Salesforce app and Lightning Experience
toastEvent.setParams({
"title": "Success!",
"type": "success",
"mode": 'dismissable',
"message": "The component successfully load."+component.get('v.recordId')
});
toastEvent.fire();
}})
I'm not unable display record Id with toast message.
I'm getting this one..
<aura:component controller="Staffbutton" implements="lightning:availableForFlowActions, force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="Staffbutton" type="string"/>
<aura:attribute name="StaffdId" type="String"/>
<lightning:button label="Success" variant="brand"
onclick="{!c.displaymsg}"/>
</div>
</aura:component>
Controller:-
displaymsg: function (component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
//fire the toast event in Salesforce app and Lightning Experience
toastEvent.setParams({
"title": "Success!",
"type": "success",
"mode": 'dismissable',
"message": "The component successfully load."+component.get('v.recordId')
});
toastEvent.fire();
}})
I'm not unable display record Id with toast message.
I'm getting this one..
for the above requirement, no need for a controller class, just place the component on any object record page, it will work. try this below code.
let me know if iany questions Thanks
Surya G
All Answers
Greeting!
your controller is working properly. If this is your full code then your controller is not getting any record id and the RecordId attribute you are using is also not initialized inside your aura component and you are not passing value inside your RecordId attribute that's why your code is not working and showing Javascript error.
If you have more in this code post it.
Otherwise, create the RecordId attribute and pass the value in it, and then it will work without any error.
If you find your solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
Your code is working fine, I have tried in my dev org where I can see the toast message with record ID. I think the problem is related to the controller, try to post your full code, we can check where it is going wrong. As of now, I see no issues with the success button and action handler.
Thanks
Surya G
what functionality do you need on click of the success button? do you want to show the record ID of staff__c object with toast message?
And what is staff button attribute? where you are passing value to that?
can you please brief me on the requirement, so we can suggest a solution accordingly.
Thanks
Surya G
for the above requirement, no need for a controller class, just place the component on any object record page, it will work. try this below code.
let me know if iany questions Thanks
Surya G