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
YWAMRTOadminYWAMRTOadmin 

Find, Update, Edit, & Save

I have created a VF page layout where a user is able to lookup a contact, the fields below the lookup form are updated, and then the user can then edit the fields. However, I don't have the functionality working.

It seems simple in my head, but I don't know the correct code to get everything working as it should. 

 

Here is a picture of the layout:

VF Page

 

Here is my code:

 

<apex:page standardController="Contact" title="Youth Street" ><p></p> <apex:pageBlock > <center><H6>THIS PAGE IS CURRENTLY UNDER CONSTRUCTION!</H6></center> </apex:pageBlock> <apex:pageBlock title="Hello {!$User.FirstName} {!$User.LastName}!"> You are viewing {!contact.Firstname}'s Youth Street Details </apex:pageBlock> <apex:pageBlock mode="find" title="Find Contact"> <apex:form> <apex:inputText value="{!Contact.Name}" required="true"/> <apex:commandButton action="{!save}" reRender="ys" value="Update Page"/> </apex:form> <apex:pageBlock title="Youth Street" id="ys"><p></p> <apex:form><center> <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </center> </apex:form> <apex:pageBlockTable value="{!contact}" var="con"> <apex:column value="{!con.member_status__c}" id="memstat"/> <apex:column value="{!con.team__c}" id="team"/> <apex:column value="{!con.Team_Leader__c}" id="teamleader"/> <apex:column value="{!con.staff_contact__c}" id="staffcontact"/> <apex:column value="{!con.school__c}" id="school"/> <apex:column value="{!con.Member_since__c}" id="memsince"/> <apex:column value="{!con.YMT_Member_Location__c}" id="memloc"/> <apex:column value="{!con.Consent_Form__c}" id="conform"/> <apex:column value="{!con.Media_Consent__c}" id="medcon"/> </apex:pageBlockTable> <apex:pageBlockTable value="{!contact}" var="con"> <apex:column value="{!con.Parent_Guardian_Relationship__c}" id="garrel"/> <apex:column value="{!con.Name_s__c}" id="names"/> <apex:column value="{!con.PG1_Address__c}" id="pg1add"/> </apex:pageBlockTable> </apex:pageBlock> </apex:pageBlock> </apex:page>

 

 So my current problem is my "find contact" field doesn't search for anything. And my Youth Street Block isn't editable at all.

 

Any help?

 

Best Answer chosen by Admin (Salesforce Developers) 
YWAMRTOadminYWAMRTOadmin

SOLUTION:

 

<apex:page standardcontroller="Youth_Street_Crew__c"> <apex:pageBlock title="Find Contact"> <apex:form >

 

<apex:inputField value="{!Youth_Street_Crew__c.Crew_Member__c}" /> </apex:form>

 

</apex:pageBlock> </apex:page>

 Youth_Street_Crew__c is my custom object with a lookup:(contact) field named Crew member.

This creates a Contact Lookup Field. 

 

 

All Answers

Rajesh ShahRajesh Shah

Didn't understood one thing.

<apex:form>
<apex:inputText value="{!Contact.Name}" required="true"/>
<apex:commandButton action="{!save}" reRender="ys" value="Update Page"/>
</apex:form>

 Here Contact is a single record.

 


<apex:pageBlockTable value="{!contact}" var="con">

 

However here, you are using the same contact in value. But the value of the pageBlockTable uses a list variable and not a single record. When a single record is used in value, nothing is rendered inside the pageBlockTable.

 

 

YWAMRTOadminYWAMRTOadmin

I found something to what I want.

It's 

<apex:inputField value="{!Opportunity.AccountId}" />

 

but I need it to look up a contact, not an account. Anyone know the syntax to lookup the contactId?

I can insert
<apex:inputField value="{!Contact.AccountId}"> and get the account lookup,

but what do I need to get the contact lookup?
<apex:inputField value="{!_______.ContactId}">???

 

Message Edited by YWAMRTOadmin on 05-07-2009 12:17 AM
YWAMRTOadminYWAMRTOadmin

SOLUTION:

 

<apex:page standardcontroller="Youth_Street_Crew__c"> <apex:pageBlock title="Find Contact"> <apex:form >

 

<apex:inputField value="{!Youth_Street_Crew__c.Crew_Member__c}" /> </apex:form>

 

</apex:pageBlock> </apex:page>

 Youth_Street_Crew__c is my custom object with a lookup:(contact) field named Crew member.

This creates a Contact Lookup Field. 

 

 

This was selected as the best answer