function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Cannot follow the same foreign key relationship twice!!!

Since today, we're experimenting a problem in All our orgs (development, sandbox, production). When the system is trying to make some queries, this errors is showing up:


Cannot follow the same foreign key relationship twice name_of_the_field__c


We didn't make any package and either install anything new. Just this morning started to crash! We're really worried about this because all our clients are stopped.


I think the problem comes from really old relationships that we've created (we've been working with SF for a long time), that have the same Child Relationship Name. But this relationships are in a package, and after conctacting with SF they don't allow to change it!


We're stuck at this point, with a case opened and waiting while our clients are stopped. Anyone else is experimenting something similar?


Any help will be really helpful.



Best Answer chosen by Admin (Salesforce Developers) 

Hi Andy!


I think they changed it already. They reverted the patch. Is it working for you now?

All Answers

Andy Freeston_LarterAndy Freeston_Larter

Hi. We are also critically impacted by this new feature. I have been using this same query for a long time without any issue up until today.


Opportunity opp = [SELECT o.Id, o.Name, a.Id, a.Name FROM Opportunity o, Opportunity.Account a WHERE Id=:coreId];


If I remove the a.Id or a.Name then the query works. Looks like the SOQL validator has been tweaked incorrectly.


- Andy


Ok, I've news about this.


The problem is happening only to mannaged packages. And it's related with the aliasing of SOQL queries.

This query, for example, produces a crash:


Select a.Id, b.Field__c

FROM Account a, a.Related_Object__r b


To solve the problem we've to remove the aliasing. The query that doesen't crash is this one:


Select Id, Related_Object__r.Field__c

FROM Account


Salesforce told us that it's related with a patch that they installed yesterday. While they're reverting or solving this, we'have to make a new package to solve the issue, changing ALL the queries that are in this format. A format which is not wrong at all.


We're really disapointed with SF for don't warn us with this patch. It stopped all our clients, and now they're really angry with us.

Andy Freeston_LarterAndy Freeston_Larter

Thanks for the update! Did you get any indication when the problem would be fixed? Changing all my queries and testing the products is going to take a week or two, an option that I want to avoid!


Incidentally, how did you get support to respond so quickly? My last critical case has been open a month and still hasn't been fixed. :(


Hi Andy,


We wrote posts at the same time :) We've also the same solution. Now we're making a build because we didn't have so many queries using alias and was easy to fix.


SF told us that they will solve it, but not when. I think they're working hard on this because it's a critical issue in the whole system. We've premium support, maybe that's why we get a response so quickly :)


I'll keep you updated with any news, ok?


Thanks for reply!!


Hi Andy!


I think they changed it already. They reverted the patch. Is it working for you now?

This was selected as the best answer
Andy Freeston_LarterAndy Freeston_Larter

Yes, all fixed. Phew! is also reporting the alias issue as being fixed.


Thanks for the update.