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
L037242283804838405L037242283804838405 

search button isnt working well

hi friends
this is the controller code:
public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
    }
     public String idNumber{
        get;
        // *** setter is NOT being called ***
        set {
            idNumber= value;
        }
    }
     public Customer__c getCustomer() {
        return customer;
    }
   
     public PageReference getCustomer1() {
    
        customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
           if(customer==null)
           {
             customer=new Customer__c();
           }
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        acctPage.setRedirect(true);
        return acctPage;
   
    }
    public PageReference save() {
        try {
            upsert(customer);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    }
    public PageReference getSpecificCustomer()
    {
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    }
    public PageReference gotoCompetitorSearch() {
    save();
    return Page.Shop;
}
}

this is the view code
<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                value="{!customer.Name}"
                assignTo="{!idNumber}"/>
               </apex:commandButton>
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

the find with getcustomer1 action isnt working.
i am a total beginner and any help will be grateful.
thanks, Liron. 
sushant sussushant sus
In the method getCustomer1 you have to get 
Id id = ApexPages.currentPage().getParameters().get('idNumber');
because you are passing this value to controller 


L037242283804838405L037242283804838405
No I am trying to do a search button
I have a custom object named Customer__c 
it has Name - string (this is the id number of the person for me)- like "12345" for example
ans 2 custom attributes-
address__c
and full_name__c
I want to make a form with 3 input fields.
the first input field gonna be the Name- means again the id number of the person for me 
near that input field will be a button with the text find. i want to create a function in my custom controller that will find the right customer by this name and if success will return to this page the customer full name and address to the 2 correct input fields. 
and if not we will see a text message you are new.
in both cases the user if new or old will be able to change his full name and address and save it and continue to the next page there its id will be sent as a parameter.

the issue is i dont have an idea how to write the find customer by Name method.
any help ? thanks again