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
jason.bradleyjason.bradley 

Change page that uses inputText component to use inputField components for lookup buttons

Hello,

 

I have an object representing an entry in a visitor log. That object has a few custom fields, Brought_by_Employee__c, Checking_In__c, Contact__c, Escort__c, Time_In__c, Time_Out__c, Title__c and Visitor_Name__c. Thus far, I've built a VisualForce page that has inputText components so that the user can type in their name, the name of the company they work for, their title in the company, etc. The page is using a custom controller that I've written with the visitor's name stored as a String. I wanted to make it easier for my users to check in if they've checked in previously and the best way to do that seemed to be to use inputFields instead because they give you a lookup button next to the inputField. At first it seemed like I would have to rewrite my custom controller to be used as an extension to the Contact standard controller in order to get the inputField working right. Then I tried just creating an empty visitor log entry, because it has a contact field so I thought that perhaps that would correclty bring up the lookup list. It did, but now I can't think of a way to get just the name of the contact they selected. Even though all it seems to be doing is filling in the inputField with the name of the contact, it looks like it's really storing the contact record itself. I need the name of the contact sent back to the controller so that the rest of the logic can be executed. I tried referencing the "phantom" log entry's Contact field to see if that was where the selected record on the VF page had been stored, but this yields the error "Error: You must enter a value" underneath the inputField. Not to mention that another inputField that was previously only required if a check box was selected also gives this error if it is not filled in. Is it possible to get this to work without rewriting my controller as an extension or is my attempt to get lookup buttons working a lost cause?

 

The first line in the constructor of the controller sets the String visitorName to testLog.Contact__r.Name. This was my test to see if the selected contact had been stored in the phantom record I had created in order to access the existing contact records. 

 

I greatly thank anyone that can give me some insight here.

Best Answer chosen by Admin (Salesforce Developers) 
SurekaSureka
Hi,

Put the components that you want to refresh in the Action Region. So only those components will be refreshed and the remaining portion of the page will remain untouched. Please refer to this link - http://harshesh7487.blogspot.in/2011/09/rerender-using-action-support-in.html

Thanks

All Answers

SurekaSureka
Hi,

Put the components that you want to refresh in the Action Region. So only those components will be refreshed and the remaining portion of the page will remain untouched. Please refer to this link - http://harshesh7487.blogspot.in/2011/09/rerender-using-action-support-in.html

Thanks
This was selected as the best answer
jason.bradleyjason.bradley

I'm sorry, I think my original post needed to be more concise. My main question was how to go about getting at the information entered into the inputFields and what it is that I'm currently doing wrong, since every inputField on the page gives me the error I mentioned above when I press the check in button that tries to get the information from the inputFields. I want to avoid having to rewrite my custom controller as an extension in order to correctly accomplish this, but if I have to rewrite it, then any tips on doing that will be greatly appreciated as well.

I thank you for that information though, I'm sure I will end up using that in the future at some point. 

jason.bradleyjason.bradley

After attempting to mess with the first proposed solution that used the "phantom" variable, I gave up and attempted to start rewriting the controller as an extension. According to the extension examples I found, mine should have been right, but I have no way of telling for sure because there were not any resources that detailed converting a custom controller into an extension. 

What I ended up doing in the end was writing another VF page that worked the same way as the lookup page that appears when the lookup button is pressed. Now my only issue is how to return records that contain names that are similiar to what is searched for.

For example, right now, if there were a contact "Test Contact", I could only obtain this record in the list if I were to search for "Test Contact" exactly. I would like to be able to find the record even if only "Test" or "Contact" or even "T" were searched for. Is there functionality such as this built into the platform that I can use instead of having to write this from scratch?