You need to sign in to do that
Don't have an account?
Dbjensen
Retrieving data in a Map from 1 of 2 records retrieved from a SOQL query
Hello - I have an object called Agent. Every sales rep has 2 agent records. One record represents an Outbound record and the other is Inbound. The field that identifies inbound/outbound is Rep_Type__c. For outbound it's SLO. For inbound it's SLI.
Below is the query I'm using to get both records.
List<Agent__c> salesAgentList = [SELECT Id, SOB_Code__c, Name, Rep_Type__c, Agent_Performance__c, User__c FROM Agent__c
WHERE SOB_Code__c IN :mapNewSalesAgntSOB.keySet() OR User__c IN :mapOfNewLeadOwner.keySet()];
The problem is, my map is grabbing the inbound record (SLI) and I need to grab the outbound record (SLO).
Map<Id, String> mapOfSalesRepType = new Map<Id, String>();
for(Agent__c agt : salesAgentList) {
mapOfSalesRepType.put(agt.User__c, agt.Rep_Type__c);
}
System.debug('Agent Rep type ' + mapOfSalesRepType);
How can I do this?
Below is the query I'm using to get both records.
List<Agent__c> salesAgentList = [SELECT Id, SOB_Code__c, Name, Rep_Type__c, Agent_Performance__c, User__c FROM Agent__c
WHERE SOB_Code__c IN :mapNewSalesAgntSOB.keySet() OR User__c IN :mapOfNewLeadOwner.keySet()];
The problem is, my map is grabbing the inbound record (SLI) and I need to grab the outbound record (SLO).
Map<Id, String> mapOfSalesRepType = new Map<Id, String>();
for(Agent__c agt : salesAgentList) {
mapOfSalesRepType.put(agt.User__c, agt.Rep_Type__c);
}
System.debug('Agent Rep type ' + mapOfSalesRepType);
How can I do this?
All Answers
try this