So I have the following scenario: I upload some data of object A, and within object A there is a field (field_b__c) which I want to use to lookup another object (B) and get a specific field (target__c) from it
The issue that I'm having is that field_b isn't an Id of B, but a field called Name which I have to use to get B.
What I have is the following:
List<A__c> b_names = [SELECT field_b__c FROM A where Id IN :Trigger.newMap.keySet()];
How do I then use b_names to get all of the relevant B objects without iterating through it and adding them one by one?
List<B__c> targets = [SELECT target__c FROM B where Name IN b_names];
Above is my half-baked idea but it's obviously not working.
One possible solution I had was to create a map so that I only reduce the number of lookups to the number of unique field_b__c's but I'm wondering if there's a better way of doing what I'm trying to do