 Hello everyone, I am Sanjay Gupta, I welcome you on Sanjay Gupta Tech School. In this video, I am going to demonstrate you how we can apply custom labels in Apex Trigger and Test Class. So in my previous demonstration, I demoed you how we can prevent deletion of a count record if active field is equals to yes. So I will be taking help of that example and will show you how we can apply custom labels in Apex Trigger and Test Class. So here you can see, this is our trigger handler where we implemented this prevent delete method. And here I am just checking if active is yes, so I am just having this message, right? And it will be shown if we are trying to delete any account record where active is equals to yes. So this is now, right now, a hard coded text, right? So if we want to change it, so we need to change it manually in this trigger handler class. And if I show you the Test Class, so in Test Class also I just use the same message here, right? So if I want to change it, so I need to change it in both the places. So it is very tricky. So in, as part of best practice, whenever you have any text message, that can be changed in future and is used in different, different classes. So what you can do, instead of writing it manually here in each class, you can just create a custom label for it. And that custom label you can use anywhere you want. So what will be the benefit of using custom label, whenever you want to change something, text message. So you don't need to change that message in individual Apex classes. Instead you will be modifying that message in the custom label. And wherever that custom label is used, it will be applied there automatically. So what we need to do in, under Home, you just need to search for custom labels. And here you will be creating a new label. So new custom label. And here we need to provide short description, the name and then value, okay? So prevent account deletion. And here I'm just copying it and pasting it as a value and I'm saving it. So now I just need to use this API name, prevent account deletion in the code. So how I can use it. So I'm just erasing it. And here I'm writing label dot prevent account deletion. So I just saved this code and the same code I'm copying and pasting in the test class. Okay. So this way same label is used here. Now anytime if you want to change the value of the label, so you can just search for that particular label and you can just click on edit and here you can change the value. So whatever value is available here, it will be applied at both the places in the trigger handler class here as well as in the test class, right? Now if you want to deploy this trigger, trigger handler and test class from like one environment to another environment. So along with these classes, you need to deploy this label as well, okay? So now if I want to show you this from UI. So I'm going to delete this record and you can see it is working fine. Now if I want to show some different values, so how I can do that. So I'm just modifying this value and I'm clicking on save. So this custom label value is modified now. So again I'm going to delete the same record and you will see that updated message. So I'm going to delete this record and here you can see the message is updated automatically. So we are using this custom label in this account trigger handler and it is being updated automatically. So from UI you can just control the custom labels and in the code you can use those custom labels instead of typing any hard coded text value, right? And here in the test class also we have used it. So if I run this test class, so it will be passing as well. So I'm just clicking on run test. So you can see it is passed, right? So there is no exception or no errors available. And if I go here and click, so you can see all the lines of this method is covered. So this way if you want to use some text in your code multiple times in different different classes, so instead of typing that code, that text manually, you can just create a custom label and that custom label you can use in any class. So benefit will be whenever you want to change the text, so you just need to change the text of or value of custom label in respective class it will be changed automatically. Don't forget to deploy that custom label along with the classes from one environment to another environment. So this way I hope you understood how we can apply custom labels in a big trigger and loss and test classes. Thank you.