• Tyler Brooks 22
  • NEWBIE
  • 30 Points
  • Member since 2022

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
When looping the list aes - I want to know if a Trading_Relationship__c exists with same Cust__c/Supp__c values. Am trying to put all TRs into nested list to check against. Is that easiest way and how do I check in the loop? Thanks
 
List<Trading_Relationship__c> trs = [SELECT Id, Customer__c, Supplier__c FROM Trading_Relationship__c];  
Map<Id, List<Id>> trmap = new Map<Id, List<Id>>();
for(Trading_Relationship__c tr: trs) {
trmap.put(tr.Customer__c, new List<Id>());
}  
for(Trading_Relationship__c tr: trs) {
trmap.get(tr.Customer__c).add(tr.Supplier__c);
}


for(Agent_Engagements__c ae: aes) {
//ae.Cust__c
//ae.Supp__c
??
}


 
When looping the list aes - I want to know if a Trading_Relationship__c exists with same Cust__c/Supp__c values. Am trying to put all TRs into nested list to check against. Is that easiest way and how do I check in the loop? Thanks
 
List<Trading_Relationship__c> trs = [SELECT Id, Customer__c, Supplier__c FROM Trading_Relationship__c];  
Map<Id, List<Id>> trmap = new Map<Id, List<Id>>();
for(Trading_Relationship__c tr: trs) {
trmap.put(tr.Customer__c, new List<Id>());
}  
for(Trading_Relationship__c tr: trs) {
trmap.get(tr.Customer__c).add(tr.Supplier__c);
}


for(Agent_Engagements__c ae: aes) {
//ae.Cust__c
//ae.Supp__c
??
}