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

help with custom controller and Visualforce page
Hi All - I need help coding custom VF page.
Users will come to this VF page(AssignContact) with url something like apex/AssignContact?ID=066540000000XzK
The ID that is passed in the URL is one of the record in my custom object(Team__c)
On this custom VF page I need a Contact lookup field which the users can lookup a particular contact , select and click save button
when users click save I would like the contact record that user selected be added to my custom object(Team)
Thanks for your help.
Users will come to this VF page(AssignContact) with url something like apex/AssignContact?ID=066540000000XzK
The ID that is passed in the URL is one of the record in my custom object(Team__c)
On this custom VF page I need a Contact lookup field which the users can lookup a particular contact , select and click save button
when users click save I would like the contact record that user selected be added to my custom object(Team)
Thanks for your help.
Try this code.
APEX class VF Page Let me know if this helps.
TEAM object does not have contact lookup field so your query on line 6 will not work. Let me try to clarify this further..
TEAM object only has ID and Name field. Contact object has a TEAM lookup field. So the way it is supposed to work is
1. user will get to the custom apex page which has team ID in the querystring/url.
2. on this CUSTOM apex page there will be ..
a. output field which will display team name
b. contact lookup input field and save button.
3. once the user clicks save .. it should update the contact record (selected in input lookup field on the custom apex page) with that team ID
All the user is trying to do is assign contact to this team.
Thanks again.
You cannot show a Contact lookup field (using apex:inputField), unless there is a Lookup relationship exists.
You have two choices here.
You can swap the Contact and Team in the above code and use it as a Contact page.
Your code will look like this.
Or, you can have Team information (in output fields) and a grid showing all the available contacts to choose from (with a checkbox probably).
So that the user can choose all the contacts he / she needs and save it.
Let me know if this helps.