You need to sign in to do that
Don't have an account?
Anupama Ramanujan 13
How can we fetch the value from Map based on particular key?
Need to fetch the value from Map based on particular key and assign to a new variable.
If Map is defined like <Id,String> then, want to check if any particular Id is existing in the Map and if it is there in map. The String value for that Id should be assigned to a new String variable. Is it possible to do? If so, how to perform this action.
If Map is defined like <Id,String> then, want to check if any particular Id is existing in the Map and if it is there in map. The String value for that Id should be assigned to a new String variable. Is it possible to do? If so, how to perform this action.
Lets say you have Map - Map<Id, String> AccountIdAndNameMap = new Map<Id, String>();
then you can check like - AccountIdAndNameMap.containsKey(Id) ;
It will give you whether perticular id exists in map or not.
if you get value then you can assign it to new String variable.
ex,
String Name ;
if(AccountIdAndNameMap.containsKey(Id)){
Name = AccountIdAndNameMap.get(Id);
}
I hope it helps you to resolve your query..