You need to sign in to do that
Don't have an account?
Visualforce problem with Contacts and Opportunities
Hi all -
I am attempting to edit a visualforce page from the "Simple Quotes" application from appexchange. My question is much like one that was asked previously here: http://boards.developerforce.com/t5/General-Development/Error-Invalid-field-Contact-for-SObject-Opportunity/td-p/160764
I'm attempting to use the Opportunity object to store information about orders. The object already includes a lookup for Account, but it did not include a lookup for a Contact, the person who would have placed the order.
I added a lookup field for Contact in the Opportunity object and want to reference it in a visual force page that generates a printable quote. Here is the code:
Account Information
Account name: {!Opportunity.Account.Name} ---> Works as expected
Customer Information
Customer Name: {!Opportunity.Contact__c} ---> This displays what looks to be an internal database ID instead of a name
Customer Name: {!Opportunity.Contact.Name} ----> This returns the error: Error: Invalid field Contact for SObject Opportunity
I don't understand why Opportunity.Contact.Name does not work as expected. It seems both the Account and Contact are both lookup relationships to Opportunity. The advice in the other thread was to query the OpportunityContactRole object, but I've never heard of this object - is it hidden from the list of objects viewable from the web interface? I've added a custom lookup field to Contact, if I query this OpportunityContactRole, will it return the same result as what the user selects in the lookup field?
Thanks for your help!
You should try {!Opportunity.Contact__r.Name} instaid of {!Opportunity.Contact.Name}.
Regards,
Pankaj Raijade
All Answers
You should try {!Opportunity.Contact__r.Name} instaid of {!Opportunity.Contact.Name}.
Regards,
Pankaj Raijade
It worked! You are a genius! Why does it work this way? Could you point me to some documentation that would help me understand?
the contact field you were trying to use is standard field so relationship is also standard.
when you are using custom field then only we need to add __r.
Regards,
Pankaj Raijade.
Please check out this application on appexchange, "Object Converter"
Using Object Converter you can convert any standard or custom object to one or more standard or custom objects with a single click of button or link