+ Start a Discussion
sessusessu 

Visual force page error

Hi I trying to insert values in two standard objects fields through page I have created a look up relation for contact from product, an error is displaying and i am not able to understand where i have done mistake. please help me.... ERROR: Error: Could not resolve the entity from value binding '{!product2.Contacts__r.Cloth__c}'. inputField can only be used with SObject fields.
Letter of Request for Purchase
Dear Mr.{!Product2.Product_Person__c}!


I request to purchase Materials used in Garments, from the{!product2.name}The intent to purchase this Material would be approved/accepted by our Organization after getting the Quotation.
* Cloth Required
* Thread Required
* Buttons
Yours Sincerely...{!product2.Contacts__r.name}
Cory CowgillCory Cowgill

When you use an InputField you cannot bind it to formula fields. You need to create an instance of the Cloth__c, have it accessable as a public attribute, then bind it to the inputField on your VF Page.

 

When you do a field like Product2.Contacts__r.Cloth__c, Apex / SOQL is treating this as a Forumla Field becuase its calculating that value at runtime from the parent record fields. You cannot update Formula Fields, so a inputField will not bind to that value.

 

Its simple enough to resolve as I said. When you query for the Product2 table, also Query for the Contact records based on Contact__c filed on the Product. Store those Contacts in your controller, and bind your inputFields to those Contact records.

sessusessu
Hi thanks for reply, now my page is saved without any error, still the name i want it to take from other object is not displaying for this i have to write its id in URL as shown in vf dev guide.[https://Salesforce.com_instance/apex/MyFirstPage?id=001D000000IRt53&cid=003D000000Q0bIE] but I am not writing any classes just page so please help me to display the name. below is my code
Letter of Request for Purchase
Dear Mr.{!Product2.Product_Person__c}!
I request to purchase Materials used in Garments, from the {!product2.name}.The intent to purchase this Material would be approved/accepted by our Organization after getting the Quotation.
* ITEM 1
Cloth----------------- 1500 Meters
* ITEM 2
Thread ----------------100 Bundles
* ITEM 3
Buttons----------------800 Bundles
Yours Sincerely...
"{!product2.Contact_Person__r.name}"