var foo = my_relationship_name;
forms[form_name].foo.loadAllRecords();
Doesn’t seem to work? I am sure the answer is somewhere on this forum, but I can’t seem to find it. I am assuming there is a preferred way to reference the relationship.
In your code foo doesn’t hold the relationship but the foundset of that relation.
So if you want to use a relationship in a variable then you need the following syntax:
var foo = "my_relationship_name";
forms[form_name][foo].loadAllRecords();