• Hazel Larot
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 26
    Replies
I am trying to update an existing code in my org to do some zip code lookup. We have an existing visualforce page with a field that asks for a zip code. I want to convert this to a lookup field that returns a list of City and State combination (example: Boston, MA) matching the zip code in my zip code custom object (ZipCode__c) and populates the City and State fields when user selects the city/state combination.

I read that I can use actionSupport to do this. I have very little experience in apex/vf so I hope somebody can help with the code.

Here's my org's existing VF page code for zip code input:
<apex:pageBlockSectionItem > 
    PG Zip: <apex:inputtext value="{!PGZip}"/> 
</apex:pageBlockSectionItem>
In the controller, the PGZip and the city and state fields are declared/saved like below:
public String PGZip{get;set;} 
PG_ct.MailingPostalCode = PGZip; 
myPageCon.PGZip = '21345'; 

public String PGCity{get;set;} 
PG_ct.MailingCity = PGCity; 
myPageCon.PGCity = 'Boston'; 

public String PGState{get;set;} 
PG_ct.MailingState = PGState; 
myPageCon.ECState = 'MA';

 
Hi,
I have very little experience in apex code/visualforce pages and need to update an existing code in our org. I need to change an apex code so that a drop down list will only display the last 2 records created for an object. The object is called ProgramCycles (which is created every year) and I need the last 2 ProgramCycles only to display in the list options. 
Current code looks like this:
public list<SelectOption> ProgramCycles = new list<SelectOption>();
public list<SelectOption> getProgramCycles()
    {
      if(ProgramCycles == null || ProgramCycles.size() <= 0)
        ProgramCycles = SelectOptions.GetProgramCycleListRecent();
        system.debug('xyzzy-in getProgramCycles')        ;
      return ProgramCycles;
    }

This code displays 11 list options, including 4 past records and 7 future records that have not been created yet. 
 
I am trying to update an existing code in my org to do some zip code lookup. We have an existing visualforce page with a field that asks for a zip code. I want to convert this to a lookup field that returns a list of City and State combination (example: Boston, MA) matching the zip code in my zip code custom object (ZipCode__c) and populates the City and State fields when user selects the city/state combination.

I read that I can use actionSupport to do this. I have very little experience in apex/vf so I hope somebody can help with the code.

Here's my org's existing VF page code for zip code input:
<apex:pageBlockSectionItem > 
    PG Zip: <apex:inputtext value="{!PGZip}"/> 
</apex:pageBlockSectionItem>
In the controller, the PGZip and the city and state fields are declared/saved like below:
public String PGZip{get;set;} 
PG_ct.MailingPostalCode = PGZip; 
myPageCon.PGZip = '21345'; 

public String PGCity{get;set;} 
PG_ct.MailingCity = PGCity; 
myPageCon.PGCity = 'Boston'; 

public String PGState{get;set;} 
PG_ct.MailingState = PGState; 
myPageCon.ECState = 'MA';

 
Hi,
I have very little experience in apex code/visualforce pages and need to update an existing code in our org. I need to change an apex code so that a drop down list will only display the last 2 records created for an object. The object is called ProgramCycles (which is created every year) and I need the last 2 ProgramCycles only to display in the list options. 
Current code looks like this:
public list<SelectOption> ProgramCycles = new list<SelectOption>();
public list<SelectOption> getProgramCycles()
    {
      if(ProgramCycles == null || ProgramCycles.size() <= 0)
        ProgramCycles = SelectOptions.GetProgramCycleListRecent();
        system.debug('xyzzy-in getProgramCycles')        ;
      return ProgramCycles;
    }

This code displays 11 list options, including 4 past records and 7 future records that have not been created yet.