You need to sign in to do that
Don't have an account?

How can i show Error messages based on error code I need show messages
Hi Everyone
I have a requirement I need to show error messages in UI Based on error codes
Error codes are provided from the client I am following the method
if(errorcode == '20002'){
component.set ('v.message','Detailes are not correct');
}
But hard coding error codes are not good practice how can I implement this functionality
Thank you
Surender reddy
You can use the Custom Labels. Store the error messages in Custom Label.
Setup -> Custom Label.
Then in Js using the below syntax you can refer the custom labels.
For Example if i have "Details are not correct" in Custom Label detailserror . Then i have to use the below code. https://www.biswajeetsamal.com/blog/custom-label-in-lightning-component/
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/labels_dynamic.htm (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/labels_dynamic.htm)
Thanks,
Maharajan.C
First you need to
Add below line in componet:-
Apex class:
Javascript Controller,
After that you can get error code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Thanks,
Maharajan.C