You need to sign in to do that
Don't have an account?

Visualforce page error - Cross objects
Hello!
I am not a developer, but I'm trying to do developing (stupid me!)
I am trying to create a visualforce page that shows Contact information as a related list on Opportunities. Below is the code that I've been working on.
<apex:page standardController="Opportunity" sidebar="false" doctype="html-5.0">
<apex:input value="Contact"/>
<apex:pageBlock title="Main Contact Info">
<apex:pageBlockSection >
Contact First Name : {!Contact.FirstName}<br/>
Contact Last Name : {!Contact.LastName} <br/>
Preferred Contact Time : {!Contact.Preferred_Contact_Time__c} <br/>
Inquiring For : {!Contact.Inquiring_For__c} <br/>
Interested In : {!Contact.Interested_In__c} <br/>
Number of Listings : {!Contact.Number_of_Listings__c} <br/>
Number of Agents : {!Contact.Number_of_Agents__c} <br/>
Number of Offices : {!Contact.Number_of_Offices__c} <br/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
This is the error I receive: Attribute value in <apex:input> must contain only a formula expression that resolves to a single controller variable or method in ContactRelatedList at line 2 column 32
I have no idea what this means. I've been googling, but can't seem to figure it out. Help!
I am not a developer, but I'm trying to do developing (stupid me!)
I am trying to create a visualforce page that shows Contact information as a related list on Opportunities. Below is the code that I've been working on.
<apex:page standardController="Opportunity" sidebar="false" doctype="html-5.0">
<apex:input value="Contact"/>
<apex:pageBlock title="Main Contact Info">
<apex:pageBlockSection >
Contact First Name : {!Contact.FirstName}<br/>
Contact Last Name : {!Contact.LastName} <br/>
Preferred Contact Time : {!Contact.Preferred_Contact_Time__c} <br/>
Inquiring For : {!Contact.Inquiring_For__c} <br/>
Interested In : {!Contact.Interested_In__c} <br/>
Number of Listings : {!Contact.Number_of_Listings__c} <br/>
Number of Agents : {!Contact.Number_of_Agents__c} <br/>
Number of Offices : {!Contact.Number_of_Offices__c} <br/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
This is the error I receive: Attribute value in <apex:input> must contain only a formula expression that resolves to a single controller variable or method in ContactRelatedList at line 2 column 32
I have no idea what this means. I've been googling, but can't seem to figure it out. Help!
<apex:pageBlockTable> instead of <apex:dataTable>
All Answers
You cannot write it like that directly. You need an extension for your standard controller.
Apex class = extension
1) the entire width of the page (just add: columns="1"): <apex:pageBlockSection columns="1">.
2) Scrollbar : https://www.thephani.com/pageblock-scrollbars/
3) Prettier? You need to play with the CSS tags.
https://developer.salesforce.com/forums/?id=906F0000000kFwCIAU
But these solutions are sometimes exclusive one of the other and for the CSS, it is unlimited.
<style type="text/css">
.outBorder
{
border:3px outset black;
}
.inBorder
{
border-top:3px dotted black;
border-left:3px dotted black;
}
</style>
You can change the colors, the borders, and so on (everything).
Here is my code (where would I update yours??):
<apex:page standardController="Opportunity" sidebar="false" doctype="html-5.0" extensions="OppContacts">
<apex:pageBlock title="Pardot Contact Info">
<apex:pageBlockSection columns="1">
<apex:dataTable value="{!myOppContacts}" var="cnt">
<apex:column headerValue="Preferred Contact Time" value="{!cnt.Preferred_Contact_Time__c}"/>
<apex:column headerValue="Inquiring For" value="{!cnt.Inquiring_For__c}"/>
<apex:column headerValue="Interested In" value="{!cnt.Interested_In__c}"/>
<apex:column headerValue="Number of Listings" value="{!cnt.Number_of_Listings__c}"/>
<apex:column headerValue="Number of Agents" value="{!cnt.Number_of_Agents__c}"/>
<apex:column headerValue="Number of Offices" value="{!cnt.Number_of_Offices__c}"/>
</apex:dataTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
You are in Lightning or Classics ?
<apex:pageBlockTable> instead of <apex:dataTable>
Datatable with CSS: https://developer.salesforce.com/forums/?id=906F0000000kFwCIAU
You are closer to your expected result.
For the test, you need to reverse the tested class creating the objects, then after the standard controller using the opportunity and finally the class using the controller. You add at least one assertion at the end in order to verify that the creation is done (the list must not be empty).
Here, there is no user action so it is a short test class like below.
If you have other mandatory fields for the account or the contact, you will need to add these fields for the creations (new).
this.oppId = stdController.getId(); // simpler