+ Start a Discussion
Suneel14Suneel14 

How to Check duplicate Name from VF page

Hi ,

 

I have create a VF Page on page i am fetching First Name, Last Name ,User Name from My custom Object User 

i want when i type username if that user name is already stored in user record then it will show a message this user name already exist .

 

Thank You !!

Best Answer chosen by Admin (Salesforce Developers) 
abhishektandon2abhishektandon2

You can use Action support to call a method of a controller

 

 

<apex:inputText value="{!productName}" id="productName" > // in this input field you can enter your user name
<apex:actionSupport event="onkeypress" action="{!searchProducts}" rerender="productSelection"/>// when ever you press key in the above input field and call a method "searchProducts" of your controller which is associated with your page.


</apex:inputtext>

 

In the controller you can check for duplicate of username and return message to your VF page

All Answers

Andy BoettcherAndy Boettcher

You could use an apex:actionSupport to push an onChange event on the textbox through to a method that queries your object for duplicate names.

 

-Andy

abhishektandon2abhishektandon2

You can use Action support to call a method of a controller

 

 

<apex:inputText value="{!productName}" id="productName" > // in this input field you can enter your user name
<apex:actionSupport event="onkeypress" action="{!searchProducts}" rerender="productSelection"/>// when ever you press key in the above input field and call a method "searchProducts" of your controller which is associated with your page.


</apex:inputtext>

 

In the controller you can check for duplicate of username and return message to your VF page

This was selected as the best answer
Suneel14Suneel14

Thank you !! Abhishek 

abhishektandon2abhishektandon2

Please accept this as Solution, if you think this is useful for you