• David Marshall 10
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I have a Visualforce page we use as a registration step for perspective clients. Currently, we use this page to capture some generic information from the client. However, we want to expand the form to allow for documents to be uploaded, which will then be attached to the Lead record that is being created. I have found code to support this; however, when implemented, it works fine if I attach both documents that I have alloted for, but if only one, or none, is attached, then the code halts after the attachment section.

Code Snippet:
public SWWRegister_Controller(ApexPages.StandardController controller) {}
    Public Attachment myfile;
    Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }
    Public Attachment myfile2;
    Public Attachment getmyfile2()
    {
        myfile2 = new Attachment();
        return myfile2;
    }
.....
if(myfile.Id == Null && myfile.Name != null){
                    myfile.ParentId = this.newMember.Id;
                insert myfile;
                }else{
                    Return Null;
                    }
                if(myfile2.Id == Null && myfile2.Name != null){
                    myfile2.ParentId = this.newMember.Id;
                insert myfile2;
                }else{
                    Return Null;
                    } 
Hoping someone can help out. I am an Administrator and my company is currently without a true developer, so I am doing my best to fill in. We have an external website where customers are able to sign up for our program, these come into Salesforce as Leads and are converted to Contacts/Accounts. Previously we used the standard Industry field on the Lead object to identify the customer's field of work, linked to the standard Industry field on the Account object. We are replacing both instances of the standard Industry field with a custom Business Type field (Business_Type__c), we're also adding two more custom fields that I will want to map in this code but haven't even begun to tackle that. The connector from the website to the Lead form is correct, but the conversion from Lead to Account does not bring over the new Business Type field from Lead to Account (the field exists on both objects). 

I thought a simple update of the Apex Code replacing Industry with Business_Type__c would do the trick, but I am running into an error stating the variable does not exist, though it does.

Original Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> industriesList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Industry', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> industriesSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        industriesList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!industriesSet.contains(item.Industry__c)){
                industriesSet.add(item.Industry__c);
                industriesList.add(new SelectOption(item.Industry__c,item.Industry__c));
            }
            if (programTypeMap.containsKey(item.Industry__c)){
                if (!programsMap.get(item.Industry__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Industry__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Industry__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Industry__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Industry__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Industry__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Industry__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Industry__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Industry)){
            accObj.Industry = industriesList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(industriesList[0].getValue())[0].getValue();
        }

        industriesList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Industry+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Industry+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}

New Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> BusinessTypeList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Business_Type__c', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> BusinessTypeSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        BusinessTypeList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!BusinessTypeSet.contains(item.Business_Type__c)){
                BusinessTypeSet.add(item.Business_Type__c);
                BusinessTypeList.add(new SelectOption(item.Business_Type__c,item.Business_Type__c));
            }
            if (programTypeMap.containsKey(item.Business_Type__c)){
                if (!programsMap.get(item.Business_Type__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Business_Type__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Business_Type__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Business_Type__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Business_Type__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Business_Type__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Business_Type__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Business_Type__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Business_Type__c)){
            accObj.Business_Type__c = BusinessTypeList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(BusinessTypeList[0].getValue())[0].getValue();
        }

        BusinessTypeList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Business_Type__c+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Business_Type__c+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}



Any help would be greatly appreciated!
I have a Visualforce page we use as a registration step for perspective clients. Currently, we use this page to capture some generic information from the client. However, we want to expand the form to allow for documents to be uploaded, which will then be attached to the Lead record that is being created. I have found code to support this; however, when implemented, it works fine if I attach both documents that I have alloted for, but if only one, or none, is attached, then the code halts after the attachment section.

Code Snippet:
public SWWRegister_Controller(ApexPages.StandardController controller) {}
    Public Attachment myfile;
    Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }
    Public Attachment myfile2;
    Public Attachment getmyfile2()
    {
        myfile2 = new Attachment();
        return myfile2;
    }
.....
if(myfile.Id == Null && myfile.Name != null){
                    myfile.ParentId = this.newMember.Id;
                insert myfile;
                }else{
                    Return Null;
                    }
                if(myfile2.Id == Null && myfile2.Name != null){
                    myfile2.ParentId = this.newMember.Id;
                insert myfile2;
                }else{
                    Return Null;
                    } 
Hoping someone can help out. I am an Administrator and my company is currently without a true developer, so I am doing my best to fill in. We have an external website where customers are able to sign up for our program, these come into Salesforce as Leads and are converted to Contacts/Accounts. Previously we used the standard Industry field on the Lead object to identify the customer's field of work, linked to the standard Industry field on the Account object. We are replacing both instances of the standard Industry field with a custom Business Type field (Business_Type__c), we're also adding two more custom fields that I will want to map in this code but haven't even begun to tackle that. The connector from the website to the Lead form is correct, but the conversion from Lead to Account does not bring over the new Business Type field from Lead to Account (the field exists on both objects). 

I thought a simple update of the Apex Code replacing Industry with Business_Type__c would do the trick, but I am running into an error stating the variable does not exist, though it does.

Original Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> industriesList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Industry', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> industriesSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        industriesList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!industriesSet.contains(item.Industry__c)){
                industriesSet.add(item.Industry__c);
                industriesList.add(new SelectOption(item.Industry__c,item.Industry__c));
            }
            if (programTypeMap.containsKey(item.Industry__c)){
                if (!programsMap.get(item.Industry__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Industry__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Industry__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Industry__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Industry__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Industry__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Industry__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Industry__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Industry)){
            accObj.Industry = industriesList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(industriesList[0].getValue())[0].getValue();
        }

        industriesList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Industry+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Industry+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}

New Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> BusinessTypeList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Business_Type__c', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> BusinessTypeSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        BusinessTypeList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!BusinessTypeSet.contains(item.Business_Type__c)){
                BusinessTypeSet.add(item.Business_Type__c);
                BusinessTypeList.add(new SelectOption(item.Business_Type__c,item.Business_Type__c));
            }
            if (programTypeMap.containsKey(item.Business_Type__c)){
                if (!programsMap.get(item.Business_Type__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Business_Type__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Business_Type__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Business_Type__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Business_Type__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Business_Type__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Business_Type__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Business_Type__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Business_Type__c)){
            accObj.Business_Type__c = BusinessTypeList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(BusinessTypeList[0].getValue())[0].getValue();
        }

        BusinessTypeList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Business_Type__c+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Business_Type__c+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}



Any help would be greatly appreciated!