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
Luke@PCALuke@PCA 

relatedList of custom objects

I have two custom objects, Setting and Customisation (British spelling). Customisation has a Master-Detail(Setting) field and
Child Relationship Name is Customisations. However
 
Code:
<apex:relatedList list="Customisations" title="Profiles" subject="{!SettingId}"/>

 Causes an error: 'Customisations' is not a valid child rationship name for entity Setting. The name right and I think I have the objects setup right. SettingId is the Id of the setting record I am using to store the information and the customisation record is related to the correct one. Seems to be moaning about the right object so I doubt its a custom controller problem.
mtbclimbermtbclimber
You must use the API Relationship name which includes a suffix of "__r".

Please try "Customisations__r" for your child relationship name.

Regards,
Andrew
Luke@PCALuke@PCA
Thanks for the response Andrew, unfortunatley I still get the same error:

'Customisations__r' is not a valid child relationship name for entity Setting

Luke@PCALuke@PCA
Got it! that with our org namespace did the trick, Thanks
JVKJVK
    Hello Luke,

I know it has been something like 8 months since you made this post, but please give me the solution to why the __r did work all of a sudden, for you even after you had the correct name __r added!

I am having the same problem. I know for sure what the name of the child in the master-datail lookup is. I add the __r and it works sometimes! Some "childs" will be displayed with the <apex:relatedlist> and some won't.

I have tried everything, plural, single, capitals, small etc.:smileysad:

Please help :smileyvery-happy:

Regards
Jeroen
Luke@TWSLuke@TWS
As far as I remember all I had to do was add the org namespace "pca" along with the custom relationship tag "r" so it was "pca__Customisation__r"
JVKJVK
Hi Luke,

I don't have a namespace set in my edition. Also the strange thing is that some of the "child's" do work with "name__r" and some don't.

Any ideas?

Thanks
Jeroen
Luke@TWSLuke@TWS
As far as I know it should be Child Relationship Name + "__r"
JVKJVK
mtbclimer,

Have you got any idea why I am having this problem?:smileyindifferent:

Thaks luke for you effort! :smileyvery-happy:

Regards
Jeroen


dkraundkraun
Jeroen,

I am having a similar problem, but I do have something you can try.  It seems like sometimes the child relationship name does not get filled in properly.  Try going to the child in the relationship (setup>>create>>objects>>choose object) and editing the details of the lookup relationship, specifically the Child Relationship Name.  That is the field that goes in the list attribute in the apex:relatedList.  Unfortunately for me, I have done this and it works everywhere except for where I need, which is the Histories child (this object is automatically created by salesforce when using field history tracking).

Hope this helps, and if anyone reading this can help with my issue, please let me know.

-David
JVKJVK

David,

Thank you for giving your comment. I investigated everything, deleted the master-detail lookup field and put in a new one, changed the names around a bit and it works!!!!!:smileyvery-happy:

But, this was in my sandbox! I than did exactly the samething in the real environment........ And NO it did not work:smileysad: So I worked around some more, once again deleted the Master-Detail field. When making the new Master-Detail I included it in every page layout, which I didn't do before. I also included activity tracking on the object, and now it works!!!!:smileyvery-happy:

I have no idea if it is because of activity tracking or the page layout, but I don't want to change it again.

I did find out an other thing, when setting up the Master-detail relationship field at one point you are asked to give the "Related list label" If you enter a label with a space, you will not be prompted, but NO Child Relationship Name will be put in the system. The strange thing is, that when you edit a Master-lookup field you see the Child Relationship Name as NOT compulsory. If you edit the Master-lookup field of a object where you filled in the "Related list label" without a space, the child relationship is compulsory!:smileysurprised:

Thanks everybody for your help, I do think this problem needs to be addressed in upcomming updates!

Regards Jeroen

CodeMonkey666CodeMonkey666
Hi,

I'm having the same problem.

The package is managed but the child relationship name is left blank so I can not edit it (eg package was published without this value being set).
So now instead of being able to pull the relatedList directly into my view, I have to code a complete custom implementation to pull the data from the db via extended controller and displaying it via visualforce. Lot's of work  ... and definitely very weak of th technology ...

is there any way one could still set this reference value? and also when we do an upgrade, set the names of these fields?

Thank you.

Luke@TWSLuke@TWS
I've noticed you don't get a relationship name generated when you have a space in the field name.
CodeMonkey666CodeMonkey666
Hi Luke,

thank you. So I guess that is a salesforce issue.

Problem now is though, how to patch this up so it works in the future and future versions of our product.

Any ideas?

Thank you!

Carl von Havighorst
Software Engineer, Convio.com