Custom Settings & Custom Metadata in Salesforce with Scenarios - 2020

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone my name is Chacon today we are going to learn about custom settings and custom enter data in Salesforce with real time scenarios by end of this video you will be able to understand what these customs are think what is custom metadata what is the difference between custom settings and my custom metadata and will also see some scenarios when to use custom setting or custom metadata or custom object with examples ok let's take this scenario so this is a library where she is a librarian and this is all the Mitchells in the library ok Here I am who is asking Harry Potter book what she will do when I ask a Harry Potter book she will go to all these shelves and then find that particular Harry Potter book and then give it to me let's say how return date and then she will take it here and then again she will put it back here so this is how library works correct now now this is the first date which I have caught a book and then again return back and then she has kept you in Hell shelf again and immediately after I have written in the book second person has come and again asked for the same book now what she needs to do walk all through the shelves and fix that again so let's say this person has also taken it and then given it after some time and immediately a third person has come again and asked for the same of what she has to do again she must walk through all these shells and then get it back here so obviously this would impact different beauty of this librarian that she needs to walk all the shells and then get it back to you in every time a person has but the same book because Harry Potter book is quite famous so many people will ask again and again right now what is the solution well librarian has become LinkedIn smart and then she has kept a little table next to her desk so this little table will consist of all the frequent last books like this Harry Potter books so today hey when I come and then she immediately picked that book and given me to me and once I returned instead of putting into the shelves she has kept it at this small table so whenever other person comes again she will just pick it up and then give it to them and then take it back and then put it at the same table so this is how the frequently asked use are being managed like this so this will obviously will increase her efficiency and productivity see so taking this analogy in Salesforce we call this neutral as custom setting and all the bookshelves are custom objects so concluding this custom settings are easy accessible data so now that you can ask so why can't we get all the books and then put it next to him so that she can fetch it easily snow it is not the place so even in library you cannot put all of them rights so there will be lot of books which means which has to be organized properly in the same way Salesforce also here you see only eight books right that table can fit in in the same way Salesforce can beat only 10 MB of data so custom setting is a place where you need to put easily accessible and frequently accessible data I hope this is clear well from that library analogy you would take away should be custom settings are stored in cache a memory which means easy to access now there are two types of custom settings one is this custom setting and second one is hierarchy so what is this list M hierarchy so list list is like same data for if we used in the organization sets very much same like custom objects so you put some data if you access I axis or some other person axis it should be getting the same data hierarchy hierarchy in essence you understood of hierarchy which means levels hierarchy levels data can be pets too based on profiles and users didn't understand no worries I will explain with you an example so list this type of custom settings which as I said lists all will get same data for every user in the organization let's say your company is dealing with some kind of support kind of thing ok so which means you need to call all the users and then get support so which means you need to store all the codes right all the phone calls so India quotes India phone number code start with 91 and USA with 1 and color is 9 7 4 3 remit 4 6 so so these phone codes will not change based on the type of user or I can say it would be same for every kind of user right so so any kind of using the sense let's say we have three type of user one is another then second one is a child another one is an infant of course child and kid cannot really use ourselves was application at this point of time but still it's fine so I just wanted to make sure there are few kind of yourself that's it ok so any user for any user these phone calls will never change which means we can store the data that static kind of data in list the custom settings now comes the higher kill so higher can sales different users can have different values so let's say Amazon using the Salesforce application where it is putting all their products in our cart in here they got a Christmas sale with discounts you see these people who are standing in a wave form and waving their hand right so these caddies are like regular users for regular users Amazon wants 10% discount on the Christmas sale in the same way they have Amazon Prime account right so there will be less set of users where they will be getting 25% of discount of course there is no special user type but I made it as a a scenario here let's say there is a special kind of users for them there is a 40% discount so if you want such kind of data to be visible based on their profile or by their user then you need to choose hierarchy so you need to ask yourself a question so if the data in here has to be accessed based on the type of user if the answer is yes okay then you should choose higher our custom setting okay now we'll see how to create the custom setting so in quick fine just search for custom setting up and click on custom setting you should be navigated to a page where you need to click on new here you can give the label name object name and if you observe the setting type is hierarchy I told you in the previous slides where I have said there are two types of settings which is list and then hierarchy but hierarchy has been selected by default and there is no way you can change it why why because it has been disabled in the backend by Salesforce because it felt list custom settings are very much outdated when it compares to custom metadata so the main advantage with this custom setting is having hierarchy as a custom setting where you can choose different data for different type of people so as this is highlighted and this has been disabled you can choose custom metadata type as an alternative but still as to showcase you I wanted to activate it how to activate it it says you can enable lists custom settings on schema settings so we'll just go back to schema settings and then you should be seeing that option so click on schema settings and at the last option is manage list custom types so we just enable it and we'll go back to custom settings again custom settings and click on it now click on you you should be seeing list has also drop-down option see list and hierarchy so fast withered sick with the list and we'll see how it looks like so I will just say country phone course like I have shown you in this lights phone calls ok and give some of the object name here country phone courts and click on save you can add some description or you can just save it now you will be navigated to the page or the detail page you need to add fields so I will add a field name called phone call because that is where I wanted to store the corn Emma so I will click on text and click on next and I will give the field label as phone code length I will give a test and Max and click Next and click Save ok it is very similar to custom object fields except there is no page layout or record type etc so we have a field and before going any further I just wanted to clear a few things as I said custom setting and custom objects are very much same except custom settings are stored in cache memory and along with that if you see where you create fields it will not have the major fields which are like they look up look up we won't find it in custom settings and you will also not find that the big list values or you won't find the long text area etc so this is one of such difference with custom setting in custom objects along with that you cannot create custom tab for custom settings ok custom objects where you can create tabs but with customs are things you cannot ok and as we have created a field which is phone code and we have a default field which is name will create records so click on manage so as this is country and phone cords will create country name and with their respective phone God so fast I will just type India and then the phone code starts with 91 ok so will create one more record which should be USA and it starts with one and we have one more record can be a cutter and we'll give it as nine seven okay so we have created three records okay now we'll go back to the list which should display all these three records I'll click on custom settings and I will open the custom setting again so if you want to open the custom details custom setting details you need to click on this if you want to see the records inside click on manage manage is a keyword or a queue that you need to understand if you click on manage you will navigate you to the record like this okay but if you click on that particular custom setting he will go to the detail page where you will also find manage again so this is a detail page of the custom settings which will have phone code and it will have the details about that custom setting from here also you can click on manage to navigate to the records or from that page you can directly click on manage link which will now get to this page this is how you can create records inside lists custom settings now we will move on to the hierarchical custom type let's click on custom settings again to create a hierarchical custom setting it will take us to the custom settings home page now this is then list custom setting now we will create a hierarchical custom setting click on new and then we can give it as Amazon Christmas sale okay this much same sale discount okay as we have seen in the previous slides will try to give discounts with this application Amazon discounts and type is hierarchy visibility set to public and then click on save now we have our hierarchical custom setting created we need to create field so click on new to create a field which fields so we are talking about the discounts so which we need to create a person so create a person field which will have the discount amount stored and then just write it as discount obviously this it's it will be in two digits leave it the decimals like that and then just click on next and click on save we have our hierarchical custom setting ready now we need to create the records as I have shown you in the previous lines we have three types of users one is the regular user second one Amazon Prime user and third one is special user so click on manage and then you should be able to see a screen like this now you might have really filled out what is this new new there are two news here unlike lists this is little bit confusing okay let me clear that for you so you see the default organization level value right this is applicable to all so you create any record under here for this custom setting it is applicable to all say in our scenario for regular users for all set of regular users we will be having 10% discount so click on new let's say it's so whoever enters into the Tama zone application we want to give them 10% discount okay click on save so 10% discount is applicable for all now so click on back to list and now we have our discontent person okay now we need to create a special or Amazon Prime users or Amazon Prime is a kind of profile that is attached to multiple users so what we will do is to create that kind of privilege to discount to set of users or to one user you need to do that under here this is for all if you want to do it for only set of users then it has to be deep down there okay so click on new here the second related list and you should be it is asking YouTube location or the profile or you can select the users so for now we call one of the profile as Amazon Prime okay so click on profile and let's say let's assume any of all proper profile is Amazon Prime so I will take Salesforce platform user as Amazon Prime just imagine Salesforce platform user whoever he is using sales was platform user or beans Kelly Amazon Prime users so click on this particular Salesforce platform user and then give discount of 25 okay which means whoever tried to access this custom setting with Salesforce platform user they would be seeing the discount as 25 percent rest others other than the Salesforce platform users in our case other than Amazon Prime users whoever logs in they will be seeing 10 if they are Salesforce platform user which means Amazon Prime they will be seeing 25 percent clear now we'll go back to the list and let's say we want to give a special a big discount to only one person or like a special persons then we can do that again so click on new and instead of profile I will select user now and I will give any person so I have only one user so obviously it is me so click on my name and then select as 40% so if I login I would be seeing this count as 40 if any Amazon Prime user or in this case Salesforce platform user logs in then he would be saying 25% discount if any other other than me and other than Amazon Prime then you they would be synced and person so this is how you can differentiate the values based on the type of users this is only possible with custom setting it will not be possible either by custom object or by custom metadata so remember anytime it comes to an hierarchy just go ahead with custom settings in the same way if you want to create few more or user something like if you want to add one more special user with or discount you can just click on it here and then you can select the user or the profile and then just give their name on the profile and with their percentages like this so let's say that get website is more to help users and then you 50 per site this you can add as many records as possible which means the level of users will define the level of discount I hope now you have understood how to create higher custom settings in Salesforce how to fetch custom setting is it like wearing of custom object no it is not custom setting needs no query I will tell you with an example so we have the library analogy right so for any book if she wants to get from that shell she needs to walk so walking two shells consider it as a query okay because it needs an effort and its needs a time right so walking to shell is a query to database so for custom set the custom object you always need to query see for shelves she has kept a little table next to her she just need to stretch her hand and then get it so which needs no effort or at least the least amount of effort that is the reason there is no need of query understand that as there is no much physical effort required understand this has norick no query required then how do we get some settings okay let me show you how to do it programmatically so we have custom object data so for custom object you just need to query like this so so understand this customer pick tell some like sample object as an APN name so I'll select ID from sample object for customs I think just give the custom setting name so like an object name custom setting also ends with underscore on skocy dot get all get all and then values get all will return the map map in the sense key and value pair right and then values will give you all the list of Records like here so the list of each you get here is the same list same kind of list that you will get it here but you don't need to use query you can just it just use these commands now we'll see how to fetch these custom settings from effects are from execute anonymous now I able to choose execute anonymous to face the records so first we'll try to fetch how to get list the custom settings from epics so I will open developer console and here I will open execute anonymous now to call the custom setting we should know its name or the API name so if I scroll down now I don't need to scroll up so just copy it and here we need to get all the records if we want to get all the records from that particular custom setting it is very much similar like custom object except there is no need of having query so list and then phone codes and then you need to give the custom setting name and custom setting have three different methods first one is get all and so get all will written the map but we need list of records so we'll get values so we can get values well you see the method right from map so get all will return all the map which is having all the records so way way put values it will just fetch only the custom phone quotes list so this is how you can fetch the custom setting records for any custom setting record just replace this name with the customs that email now we'll see whether we caught it or not we need to display these phone calls we can directly just give a system door debug lock but to display it properly I am just putting that inside a for loop to display the records phone cord and phone cords so I am looping through all the records and then giving you system dot debug lock and in here I will just kill phone cord yeah so done so we are looping through all the records and then it should display all three of the records India USA and Qatar click on execute and it should create a log down here so click on that log and if you want to see only the debug log statements you just need to check this box and we should be seeing three records right so if we scroll right phone core 91 194 974 which should be India USA and haha see they're using cotton this is how you can fetch all the records from a list custom setting but if I want to fetch only one record only one record or a specific rivets I want only India's record or if I want to have only the USA card then how so we have a way as I said there are three methods so as this method is get all okay get all method now our second method is get instance so get instance method will get only one record if you want to get only one record just put that record directly instead of putting a list and then phone cord give that one that custom setting name and then get in stance and you just need to give the name of that particular record so if I ask for India it should fetch it so a system door debug log and then phone cord should display all the details about that phone cord so I will just click on execute second log has been created click on it and then just click on this debug only checkbox it should display this record so if you scroll right 91 is the phone code and it's the other details last one Friday it's a tab user name India in the same way if you change the name just the name then you will get USA and then click on execute it should get the USA record so I will get 1 more debug block and then click on debug only should display only the USA record c1 and finally USA see this is how you can get single records so we have two methods that we have spoke so far we will see about the get values method when we discuss about the hierarchical method okay now this is how you can fetch custom settings in epics so along with these methods you can still call you can still call the custom settings by using words something like this see just copy paste these and then phone cords is equal to we can just ask for select ID name and then phone code value I am assume it is scored from so just click here and then same logic as this so just copy a paste is for loop and we got what we want okay so phone calls phone course I will just run this query and execute so you can still call custom settings from soql as well but that is not at all recommended just for your information I am Telling You that Spokeo can be used still on custom setting okay click on debug only and you should be seeing all this records see now we'll see how to get hierarchical custom setting so Amazon sales discount is basically the hierarchical custom setting we have the AP name we just need to copy this and open the execute anonymous and debug execute anonymous and then I will comment down everything that I have done and go up and then just get that particular so this is our custom setting so I will just give Amazon discount and then I just need to copy that again and use get values and inside I can give my username or I can user IDs for a I mean say user ID or profile ID or I can let it to blank so if I give user ID or profile ID it will fetch the relative record which is associated with that user ID so you can get really never write user info dot get user ID is a function which it will get the current logged in user ID so this is a stand since what function so with that it really get my phone user ID say pay past this user ID out of all these three records so there are three records created right see if I open this record it should have around 40 right yeah forty percent so that value is something which needs to be fetched so I have got that user ID and then I will just debug I will put a system load debug log statement then amaze this let us see how this is working just click on execute now we have our new execute anonymous debug log and then click on debug only which should allow us to get 40 percents so this is how you can fetch custom settings data which is this custom setting and hierarchical custom setting from epic now that we have understood what is custom setting how to create it and how to fetch it we need to see the advantages with the custom setting you can just you can use get all taught values and you'll get all the reports in that custom setting and as it is placed in cache in memory it is faster access which increases the performance right and it biggest advantage with custom setting which no other tool will provide is hierarchical custom setting that allows different data for different profiles or users as you have seen Amazon prior regular users and these special users will be getting different kind of discounts as you have seen in the analogy like the other side of coin we still have the disadvantages with custom setting as well so custom setting data cannot be deployed so we have the custom setting at the table right so we'll put some data which are both like these phone calls or like the discount personally the sec cetera these cannot be deployed to the other and we're on watch you can just send the table and then you just need to download the data and then put it in the other environment with data load or awesome data migration tools and the second disadvantage is there can be only 300 fields that are allowed in custom settings so you cannot create more than 300 fields in a custom setting okay and custom setting counts against total number of custom objects in organization so there is a maximum limit in creation of custom objects so custom setting and custom object both are same in terms of object count and he finally said one days is tabs cannot be created in custom settings like we have account contacts time or custom object tabs we cannot create custom setting tab we just need to go to setup like I have shown you and then see the data inside oh how can we manage with this disadvantages don't worry we still got custom metadata which might clear all our custom setting disadvantages okay let's explore a custom metadata custom metadata is very much similar to custom setting except this is deployable across environments as we have seen one of the disadvantage with custom setting is we cannot deploy custom setting data to the other environment but custom metadata has an ability where the data insert custom metadata can be moved across different environments or sandboxes example so left sorry sandbox and right side is a production environment so custom setting has custom setting has records so when we deploy it in the change set we can only deploy custom setting table Northey records so if you go to production and then see where the what we have deployed we can only see custom setting with no records so to have our records we need to download all the records which means exported and then import it again in the production environment the data I cannot be deployed by a chain search or by a wire and or in that matter any tool but when it comes to custom metadata which is having records you can deploy custom metadata along with customer records which change it which means we can deploy custom metadata along with its record to the production environment or in that matter any environment in the chain sets this is the biggest advantage which any other thing cannot do example custom object or custom setting cannot do oh that's so cool I don't need to export an import data instead we can just deploy right we can just you probably don't need to export and import data again and they can in them so custom metadata this is the biggest advantage that we have now we will see how to create custom metadata so custom metadata are very similar to custom settings except custom metadata records can be deployed into the other environment and the common point between custom metadata and custom setting is both of them will stay in cache memory which means both of them are very easy to access and if you have any requests that are frequency needs to be accessed put it in make a custom metadata custom settings prefer custom settings when there is a need of hierarchy kind of thing if it is not then go ahead with custom metadata that's an easy approach now so we have the custom and ability of our custom metadata as well create country codes custom metadata so as you have seen in custom settings list custom setting is very much similar to custom metadata so custom metadata is more advanced because it can be deployed into other in romance with ease so if you want to use this custom setting you need to prefer custom metadata rather than using this custom setting so we'll create country codes loader will also be same and then click on save and your custom metadata is ready you need to create a field so it has standard custom fields along with that you will also have validation rules which custom settings doesn't have you will also have page layouts which doesn't have it in custom settings so custom metadata can be like more than a custom setting and less than a custom object okay and more our with custom entity type data type you cannot create tabs ok you cannot have a tablet customer advocate I if you see you can create a number of fields you can have a lookup relationship with another metadata lookup relationship can only happen with another metadata not with any other custom object or with any custom set ok and along with that you will also have fake layers you'll also have long text area which doesn't have it in custom setting that is the reason I said custom metadata type is more than a custom setting less than a custom object ok so I will create a simple text and then click on next which will take us to the next screen and give a label name I will give it as form for like we did it in discussing setting and give it as 20 click on next and click on save now we have our custom metadata which is having please ok so custom metadata would have standard fields as label and name prefix and we'll have corn code which we have with it in custom talking now as you already know validation rules you can put any validation rules bail out you can change it so as I have told you in custom settings manage is a world where you just need to click on it so that it will take us to the record stage okay now we will create couple of Records so label name could be India again and then country code will be automatically populate this is a label this is the name and here we can give it as +91 similar to what we have given in custom setting will create one more and which it will be USA and plus one and seven you and will create one more which is for qatar and you have nine seven four so we have three clearly calls created with custom settings or custom metadata so we'll go back so custom metadata here you can pick manage because like we did it in custom settings you click on it it will navigate to this page where you will have all these things so this is how you need to create custom metadata so how to get custom metadata here so like the custom object data where we query eight sult ID from sample object in the same way custom metadata should also be queried like this so where yeah one more thing so for custom metadata it will end with MD et which means custom metadata for custom object and for customs I think it will end this underscore underscore see here its underscore underscore md t so like custom object we also need to query metadata like this to get the data so like custom setting we cannot just use a method to get it oh i need to query custom metadata that's bad right so custom setting hasn't that privilege but custom metadata doesn't so custom metadata you always need to query to get the data but there is a catch here soql with no : limit is our metadata so as you already know there is a limit of hundred so culés you can use it in this single transaction but if you use your query on custom metadata it will not count example let's say you have already used to 10 queries in your transaction but in the levant the query eat it is the query on the custom metadata but that xi 1 will not be counted why because you wearing the metadata metadata queries k will not be counted against econo limit so you don't need to worry about the Karuna limit you can use as frequently as possible if you need to get the metadata now that we have understood how to create a custom metadata type we need to understand how to fetch it so to fetch this custom metadata unlike our custom settings we need to query it like custom objects we need to query this custom metadata recourse so as I have told you custom this custom metadata type ends with underscore underscore MDT can lead in the sense metadata for custom settings it is on the spurns Corsi for custom metadata it is underscore underscore md t okay so we'll go to the upper console again to query how these custom metadata and we'll do the execute anonymous the candy bar so to get these records we need to query it and put it in a list so codes and then give the label and then we have created deep own code right phone Quran scorns Co see from the list okay now we'll run for loop around this list so that we can run over how we can display these codes codes and then system dot debug rotate yep code okay now if we run this way should see all those records in the debug lock so click on this so this checkbox debug only checkbox allows you to see all your debug statements and see Qatar India USA 9 7 491 n1 so this is how you can query your metadata records from epics and now you might ask so custom setting is also storing in cache memory and custom metadata is also storing in cache memory then why do we need query for custom metadata and not for custom setting so based on the design custom metadata needs to be queried but Salesforce has given a feasibility third even though we queried these custom metadata that will not be recorded under donor limit so what does that mean so we have our key back only right so if you see here so the total counter limit in a single transaction for a spoke your queries are hundred so we have all the consumed 1s local here right so if you see in this debug logs if I scroll down the transaction will be there but it will not record it as it ran a query see it says number of soql query 0 out of 100 so any soql query on metadata will not be counted on governor limit so this is something which you need to understand let's say I query on accounts now that will had that should add that number there so I will just show you how it looks like select ID from account ok and now I queried execute his complete statement and now this should have number of queries is equal to 1 out of 100 so down see it says 100 1 is on account to have a hundred is total government that is how it works so now I will add one more query on this custom a metadata again then also it will not query it so the wrong so it will not add it in the tournament I'll just change the name so there are two queries on metadata one query on account but it will count only one why because these are two worth metadata queries so I will just execute and now you should still see one there even though it has queried three times metadata queries will not be counted against the Karuna limits so I can use as many as you want see this is how you can query your metadata from your epics so a whenever use metadata don't worry about soql it's not at all counting I hope this is clear so highlights of the custom metadata we can use validation rules on custom metadata so in custom settings we cannot have validation rules or page loads like the second point so we have the privilege of adding validation rules and page layouts in custom metadata like we have it in the custom objects now we can create lookups to another custom metadata like we are doing it in custom object example full-contact is having lookup to account write in the same way we can have custom or chikhloo cups on some other custom objects etc except for these kind of things can also happen in custom metadata but this is not possible with custom settings these are the major highlights with custom metadata along with a deployable feature now comes with the disadvantages of this custom metadata so custom metadata is having couple of disadvantages like we are having with the custom settings estimated rate order also doesn't have an option to create custom tabs so like our custom objects you have the custom objects where you have tabs but not for custom settings and custom metadata you just need to go to setup and then open the respective custom metadata and then you need to click on manage records to city records and the other disadvantage is you need to query to get the data so coiling should be there like our custom objects custom setting is only having the option of getting the viateur with functions ok we will see the difference between custom setting and custom metadata so custom setting doesn't need queries as you have already seen it just need a method called get all dot values so custom setting but get all dot take values will return all the records in the custom setting custom metadata needs query to fetch the data like you have all these same custom object and custom metadata needs query to fetch the data and custom settings are easy to access and in the same way custom metadata also easy to access and easy to deploy as well because if the data inside metadata can be deployed at across environments but it is not possible with custom settings now the third difference is custom setting allows different data for different set of users by hierarchical custom type so based on the users are like I have shown in the amazon prime example so different type of users in amazon accounts will have different type of discounts which is not possible with custom objects or with custom metadata now with custom metadata the other highlight here is custom setting allows validation rules and page outs which is not possible with custom setting the other common thing with custom setting and custom metadata type is we can use those custom settings and custom metadata in formula freeze formula fields yes formula fields how so firk settings it will only work with hierarchical custom settings informal appeals not the least custom settings custom metadata types can be directly called so we'll go to fields and we'll try to create a discounts as we have already know our custom setting we have created right Amazon sale for each of the user differences so I'll create an account and will create I'll create a discount field here and then that discount should get the value from that custom setting based on the user so create a formula field and then click on next and then give the value as Amazon discount and scroll down you must desert and type and then click on next and then click on yeah in advanced formula you need to click on insert field and if you see there is a set up and with setup you have your custom setting which is Amazon discounts we have the custom filter which we have created so it will list on all the custom fields so we have our discount feed so now this discount field will fetch the discount value based on the user or profile that user is logged in now click on next as I am she can't I am a special user in that custom setting side so we have three kinds of user one is reg'lar second one is Amazon Prime and third one is specialize user which is Vega Shrikant as Vega Shrikant is having 40% chance is privileged discount if I create an account now it should get that discount value as 40 will see whether it is working properly or not click on account now we click on now we will click on new and then try to create a simple account ABC and then click on save and it should save the record and now if we go into the details and scroll down it should fetch the amount this Amazon discount as 40 why because the custom setting is having my name and which is having with a discount of 40% age if you are Amazon Prime user which is Salesforce platform user then you would be seeing this as 25% if you are none of them then you would be saying 10% that's how the custom setting works in the formula please as we were able to use this Amazon Christmas same discount value 40% in the in formula field right in the same way we can get our metadata into the formula field as well so let's open the custom metadata first and then we'll see how to get that value so we have our country course where we have multiple values right India India Qatar and if you open India I would be seeing that phone call now we'll try to get this phone code in our formula face so we'll go to setup by object manager and then we'll create a new fill in account itself so account and then feelings and relationships and create in your field so a new field we will create should be a formula field and then click on next and here we need to give it as form code and written type should be text and then click on next and in here in that ones formula click on insert field and you should be seeing custom metadata right so click on this my custom metadata and you would be seeing color country codes so we have multiple metadata to display there and in here out of our three records which one do you want India or Qatar or USA so I choose India here and then it is asking which field I want to fetch I want phone code field and click on insert so these kind of values can be used in custom validation rules also let's say this phone call is not equal to India Court and given error if this for discount is not greater than 10% and given up it's something like that so we have our formula ready and then click on next and then again click on next and then click on save so we have our formula field ready which is fetching the custom metadata now we'll see whether it is working properly or not by opening again sorry creating an account so click on accounts and then it should now get to the accounts page where I can click on new and then create a new account something like CDE and then click on save it should create a record and if we go to detail and the town there we should be seeing ya see phone call as 91 as we have selected India 91 if you would have selected us save one if it is cata mind some people that's how custom metadata formula works like this and custom settings formula work like this so for the information again custom setting with that is hierarchical custom setting only works with the formula fields we can use this custom metadata validation rules as well not only informal effects but also in violation rules ok quiz time so we have a scenario where ABC corporation needs to store its data in a table that has to be frequently accessible and easy to access by the user which one - its custom object or custom settings or custom metadata people who wants to answer by themselves posit here I am going to answer it now so whenever you see frequently accessible and easy to access it is like a cache memory so cache memory in this sense the answer can be a the custom setting or custom metadata so which one to choose is like we will be having more conditions on it let's say if you want to have a hierarchical kind of thing then you need to go for custom settings but you want to deploy your data to the other environments then you need to choose custom metadata but for this scenario as it is frequently accessible you should go ahead with either custom settings or custom metadata ABC corporation needs to store its data in a table and there should be a tab in user interface which one to use custom object or custom setting or custom enter data as soon as you see tab there you should understand that neither custom setting nor custom metadata can do this only custom object has the ability to have a custom tab in Salesforce so the answer is obviously custom object okay now question number 3 ABC corporation needs to store this data in a table and I should be able to get the data without using a query which one to use custom object custom setting or custom metadata so as it says data without using query so without query is obviously we have custom setting so the answer is custom setting later custom object or custom metadata cannot get the data without using a query ok now question number four ABC corporation needs to store its data in a table and I should be able to get this data in formula fields for any custom objects which one to use custom object custom setting and custom enter data so take time it's a little tricky question so which one to use so the answer is both custom setting and metadata can be used in formula fields of any custom object as I have shown in the demo you can use custom setting or custom metadata in your formula fields or for that matter validation rules for any custom object clear question number 5 ABC corporation needs to store its data in a table and I should be able to get data based on different users which one to use custom object custom setting or custom metadata so as soon as you see custom data based on different users so data based on different users since basically in hierarchy so you how to use only custom setting neither custom metadata custom object has that feature so you can use car hierarchical custom setting to have data based on different users okay now the last question ABC corporation needs to store its data in a table which is easily accessible with the validation rules in its place so which one to use and I say this is also a tricky question custom object or customs I think are custom metadata so here you need to find two items one says easily accessible so easily accessible can be a custom setting or custom metadata and it says validation rules validation rules can be custom object and custom metadata so when it says easily accessible with validation rules only custom metadata means the requirement custom metadata easily accessible and it can have a little rules custom entered object is not easily accessible it has validation rules though but it is not easily accessible custom setting is easily accessible but not validation rules so the answer is custom metadata of course with that we are done with all our quiz items I hope you have understood the clear difference between custom setting metadata and custom object and I hope this is very helpful to you to choose which one is better in your business scenarios and that's a wrap up if you like this video give a thumbs up practice practice practice happy learning and bye
Info
Channel: Salesforce Exclusive
Views: 47,875
Rating: undefined out of 5
Keywords: Custom Settings & Custom Metadata in Salesforce with Scenarios, custom settings salesforce, custom metadata salesforce, salesforce custom settings, salesforce custom metadata, custom metadata in salesforcce, custom settings in salesforce, difference between custom settings and custom metadata, custom metadata, custom settings in formula fields, custom metadata in formula fields, custom settings apex, custom metadata apex, hierarchy custom settings, list custom settings
Id: zxQu0Ozo4G0
Channel Id: undefined
Length: 46min 32sec (2792 seconds)
Published: Wed Jan 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.