You need to sign in to do that
Don't have an account?
Nicholas Ferguson
Invalid bind expression type of sObject does not match domain of foreign key
I'm attempting to write a trigger on 'before insert' and 'before update' for ObjectA__c. In my code I have a need to find related records based on a custom lookup field.
ObjectA__c has a custom field we'll call ObjVersion__c.
ObjectB__c also has a custom field we'll also call ObjVersion__c.
Both of these lookup fields are related to a custom object 'Version__c'.
When ObjectA__c is inserted or updated, I'd like to look at the ObjVersion__c field on the update and find all the ObjectB__c that also have that relationship to that Version__c object.
However, I get an error stating:
What would be the proper way to accomplish this in a SOQL?
ObjectA__c has a custom field we'll call ObjVersion__c.
ObjectB__c also has a custom field we'll also call ObjVersion__c.
Both of these lookup fields are related to a custom object 'Version__c'.
When ObjectA__c is inserted or updated, I'd like to look at the ObjVersion__c field on the update and find all the ObjectB__c that also have that relationship to that Version__c object.
List<ObjectB__c> areas = [ SELECT Name, ObjVersion__c FROM ObjectB__c WHERE ObjVersion__c IN :Trigger.New];
However, I get an error stating:
Invalid bind expression type of ObjectA__c does not match domain of foreign key
What would be the proper way to accomplish this in a SOQL?
I hope the below code will help you. Thanks,
Sujeet
Can you explain your requirment clearly. What are you trying to update using trigger?
As per your query description, you can query the objectb records based on Version__c field as like below.
Thanks!!