+ Start a Discussion
skr00skr00 

Erron on Pg. 257 of Developer Guide (Advanced Programming Tech)

Hi All

 

Below is a part of code on Pg. 257 of Developer Guide Advanced Programming.

 

<apex:pageBlock>
<apex:pageblockTable
value="{!Position__c.Job_Application__r}" var="JA">
<apex:column value="{!JA.Candidate__r.First_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate__r.Last_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate_Qualified__c}">
</apex:column>
</apex:pageblockTable>
</apex:pageBlock>

 

Error recvd while saving on under developer mode.

 

 

Just wanted to know if anyone faced the same problem. All the Objects & Fields are created through Code Share Project. Job_Application is a Custom Object (Junction Object) between Position & Candidate Objects.

 

Any solution, much appreciated.

 

Thanks & regards,

Pri..

 

 

 

hisrinuhisrinu

It appears to be the relationship field API name in your instance is wrong, review the relationship name using force.com explorer or by navigating to the Job Application object->Position lookup relationship name

skr00skr00

I hv checked all the errors & API names.I really have no clue how to refer a relationship in API. Just following the instructions on the book & got stuck here for more than 2 days & can't even proceed further as everyt

hing is based upon this. The problem is with the book as everyone in our batch faced the same problem (no solution).

 

Error: Invalid field Job_Application__r for SObject Position__c. 

bob_buzzardbob_buzzard

Looking back at my dev org where I worked through this code share, my relationship field name is:

 

Job_Applications__r

 

Does that help?


skr00skr00

All the objects are created through Code Share Project & i tried with Job_Application__r & as well as Job_Application__c. Still receiving the same error. Even our trainer could n't help on this. Any otner expert advise of yours?

bob_buzzardbob_buzzard

Did you try with Job_Applications__r as posted above?  Note the additional 's' before the __r suffix.

skr00skr00

Yes...i tried & still receiving the same error. Here is a print screen

 

 

Username: wsxqaz106@gmail.com

Password:

password@1

 
skr00skr00

Code set given is:

 

<apex:page standardController="Position__c" id="thePage">
<apex:form>
<apex:pageBlock>
<apex:pageMessages></apex:pageMessages>
<apex:pageBlockButtons location="bottom">
<apex:commandButton
action="{!save}" value="Save">
</apex:commandButton>
<apex:commandButton
action="{!cancel}" value="Cancel">
</apex:commandButton>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField
value="{!Position__c.Department__c}">
</apex:inputField>
<apex:inputField
value="{!Position__c.Job_Description__c}">
</apex:inputField>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock>
<apex:pageblockTable
value="{!Position__c.Job_Application__r}" var="JA">
<apex:column value="{!JA.Candidate__r.First_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate__r.Last_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate_Qualified__c}">
</apex:column>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

bob_buzzardbob_buzzard

If you use the schema explorer on eclipse you should be able to find out the name.

 

Open your project in ecipse, then double click on salesforce.schema.  When that apears, scroll down the right hand side to the Position__c object and open the child relationships.  You should see the exact name in there.

skr00skr00

Here it shows "Job_Application_c" but in the book they have mentioned "Job_Application__r" which is contradicting. The error is on line -

"<apex:pageblockTable value="{!Position__c.Job_Application__r}" var="JA">"

skr00skr00

 

"Job Application" custom object has 2 Master Detail relationship with "Candidate" & "Position"

 object. How i can get the recrods associated with "Job Application" (this is a junction object) with output like

 

 

 

 

bob_buzzardbob_buzzard

When you expand the Job_Application__c (as you seem to have done), you will see an entry Relationship Name - in my case its:

 

Relationship Name: Job_Applications__r

 

What is the name on yours?

bob_buzzardbob_buzzard

I don't think a relationship name ending with __c is even legal.  Can you post the expanded form of that relationship from the schema explorer?

Starz26Starz26

Just a shot in the dark but.....

 

could it have been misnamed (probably not as the first picture with the api name does not show this) Job_Application__c for the name and the relationship is Job_Application__c__r?

 

Just an out of the box guess and we would need to see the expanded tree for Position__c that shows all the child relationships with the relationship for Job_Application expanded as well.

bob_buzzardbob_buzzard

Woah.  So the name that you need to use in visualforce is the R00N3000....__r .

 

As an aside, that looks quite like a salesforce id, but regardless, that is the string that Visualforce is expecting in order to traverse the relationship.

bob_buzzardbob_buzzard

The image comes through as a broken link.

bob_buzzardbob_buzzard

Same thing again.

skr00skr00

'm facing some issue in pasting the Error image. However

that also didn't work.

 

Error msg was: ErrorError: Invalid field R00N30000002btIBEAQ__r for SObject Position__c

skr00skr00

I have 3 custom objects - Job Application, Candidate & Position. Job Application ia the Master (Junction Object) & related to Child objects Candidate & Position individually through many to one relationship. I want to pop up records associated to Job Application through the below code. First & Last Name along with candidate qualified fields are present in the object.

 

 

<apex:pageblockTable
value="{!Position__c.Job_Application__r}" var="JA">
<apex:column value="{!JA.Candidate__r.First_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate__r.Last_Name__c}">
</apex:column>
<apex:column value="{!JA.Candidate_Qualified__c}">
</apex:column>
</apex:pageblockTable>

 

Output that i require is:

bob_buzzardbob_buzzard

In the schema explorer, check the box next to Job_Application__c and then click the run me button at the top of the page, next to query results.

 

The query that is generated will be pulling records from the relationship - can you post what is generated?

bob_buzzardbob_buzzard

That relationship is pointing to a Candidate__c sobject - that implies that you have expanded the Candidate__c sobject rather than the Position__c sobject.

bob_buzzardbob_buzzard

Not sure what that last screen shot was supposed to show - can you post the shot of the expanded Position__c child relationship for Job_Application__c.

skr00skr00

Total List 15, the last 3 records are

 

 

i can't post more than 20000 characters at a time.

 

 

bob_buzzardbob_buzzard

I don't want you to post the result of the query - I want you to expand the Position__c sobject child relationship for Job_Application__c in the schema explorer.

skr00skr00

@Bob

 

I found the solution. I just pasted "R00N30000002btlAEAQ" & it worked fine.

 

Thank you so much for all u r effort & tolerating my trouble.

 

ca2kumar@gmail.com

 

Pri...

bob_buzzardbob_buzzard

No worries - glad to hear you got there.

skr00skr00

@BOb.....i might trouble you in future.