You need to sign in to do that
Don't have an account?
VINODKUMAR REDDY KALUVA
How can I avoid nested for loop in the below code?
Can anyone help on avoiding nested for loop in the below code:
List<Account> leadAccountIds=[Select Id, OwnerId, Name FROM Account WHERE Name LIKE :Liktr]; System.debug('leadAccountIds=' + leadAccountIds); Map<String, Id> acctNameId=new Map<String, Id>(); Map<String, Id> acctNameOwner=new Map<String, Id>(); if(leadAccountIds.size()==1){ For (Account a :leadAccountIds){ acctNameId.put(a.name,a.Id); acctNameOwner.put(a.name,a.ownerId); system.debug(acctNameOwner); system.debug(acctNameId); For (Lead l2:trigger.new){ l2.ownerId=a.ownerId; system.debug(a.ownerId); } }Thanks in advance!....
Prema -
You can use List<Lead> l2=[select ownerId from Lead WHERE ID IN: Trigger.new]