You need to sign in to do that
Don't have an account?
devendra dhaka
Map autoPopulation
I am tryin to create a MAP
Map<LeaveType__c,Leave_Policy__c> additionalLeavePolicy =new Map<LeaveType__c,Leave_Policy__c>([ SELECT Maximum_Allowed_Credit_for_Leave_Type__c,LeaveType__c,Next_Execution_Date__c,Action_Taken__c FROM Leave_Policy__c WHERE RecordType.Name='Additional Leave Policy']);
Set <LeaveType__c> lt = additionalLeavePolicy.keyset();
system.debug(lt.size);
will it work ??
AS
Map<ID,User> Usr = new Map<ID,User>([SELECT name,TITLE FROM User WHERE Id IN : ownerIdList]);
IT WORKS ??
No, if you use the map constructor that takes a collection of sobjects, your map needs to be keyed by ID. If you want to key by another field, you have to create the map, then iterate the collection and put each record into the map individually.
Map<ID,List<Leave_Balance__c>> lbMap = new Map<ID,List<Leave_Balance__c>>();
for(Id id: ltFromLeavePolicy) // ltFromLeavePolicy is a LIST<ID>
{
List<Leave_Balance__c> lbList = [SELECT Leave_Credit__c FROM Leave_Balance__c WHERE LeaveType__c=:ID];
lbMap.put(id,lbList);
}
Now i want to iterate over LEAVE_BALANCE__C list inside another for loop,
for( )
{
for(Leave_Balance__c lb : lbMap.values()) // will this work ??
{
}
}
Or how do I achieve this ??
Not quite - you'll need to iterate the keys, then pull back the list of Leave_Balance__c objects and iterate those.
E.g.