+ Start a Discussion
Brendan LallyBrendan Lally 

Maps, cross object join tables and accessing complex multi-relationship record objects

I get a compile error if I try and create a map of a x-object join table

I have object A and B with a join table of AB

If I try the following I get the following - compile error - Invalid type:AB
..Map ab_recs = new Map();


does this mean that x-object join tables cannot be 'mapped'


I know I can run a query that gives me data from A and B via __r but how do I setup an (map) object to receive them. Will this work if its a List?
for example
I can setup
...Map a_recs = new Map();
and happily read in an 'A' record and access its fields via a_recs.get.(i).fieldname
but if I do a query where its pulling back parent/child related recs via __r or '.' notation HOW is that mapped now?
Can't c how I can do a a_recs.get(i).parentfieldname?

don't c any info on this in docs/cookbook etc.

Lal
Brendan LallyBrendan Lally
Get the same error if I try and create a List object for AB
.. List ab_recs = new List();


PS I'm trying 2 do this within a trigger

So how do I process this recs and 'map' the data from
[select field_ab1, fieldab2, fieldab3, a__r.fielda1, a__r.fielda2, b__r.fieldb1, b__r.fieldb2 from ab]
where I now have 3 'chunks' of different objects - ab, a and b ?

Lal
Brendan LallyBrendan Lally
ignore that I've missed out brackets etc.. redg syntax (Opera seems 2 strip them out and its inline editing for whatever JS control SF forums uses just doesn't work)
Brendan LallyBrendan Lally
works ok now, no compile error so must have had a char in there that I didn't c.

However how to map that complex object back is still a ?
I'd like to use MAP but not sure I can access the right fields. will play and c


Lal