You need to sign in to do that
Don't have an account?
It'sSaurabh
I have List of users stored in Custom Metadata, and now i want to check if the running user (Userinfo.getname()) is available in the list that i queried from custom metadata how to achieve this,
I Tried doing in below way, Please help
List <DET_Allowed_users__mdt> Userlist = [SELECT Id, Users__c FROM DET_Allowed_users__mdt];
List<String> str1 = New list<String>();
for (DET_Allowed_users__mdt Det:Userlist);
str1.add(Det.Users__c);
System.debug('see this '+str1);
String str = Userinfo.getname();
if(str1.contains(str) ){
List <DET_Allowed_users__mdt> Userlist = [SELECT Id, Users__c FROM DET_Allowed_users__mdt];
List<String> str1 = New list<String>();
for (DET_Allowed_users__mdt Det:Userlist);
str1.add(Det.Users__c);
System.debug('see this '+str1);
String str = Userinfo.getname();
if(str1.contains(str) ){
Looks like List contains method is case sensitive ... Use the below
Please mark as best answer if the above helps...!!!