You need to sign in to do that
Don't have an account?
Holly Havelka 10
Dynamic Search For Account Name Field
Hi all,
I have this controller and component which allows for a dynamic search to help candidates select the name of the right college account. I want to display other criteria for the end-user in the 'results table' so that they can choose the right account, especially if there are duplicate account names that appear in the search results table. For example, I would like to add the ability of city, state to be displayed when they search for the account name.
Here is the controller:
I have this controller and component which allows for a dynamic search to help candidates select the name of the right college account. I want to display other criteria for the end-user in the 'results table' so that they can choose the right account, especially if there are duplicate account names that appear in the search results table. For example, I would like to add the ability of city, state to be displayed when they search for the account name.
Here is the controller:
public class ProfileSubmitController { public List<SelectOption> genders { get; set; } public List<SelectOption> ethnicity { get; set; } public List<SelectOption> eligibleToWorkUS { get; set; } public List<SelectOption> freeOrReducedLunch { get; set; } public List<SelectOption> grantPellRecipient { get; set; } public List<SelectOption> parentsHighestEducation { get; set; } public List<SelectOption> states { get; set; } //public List<SelectOption> collegeList { get; set; } public List<SelectOption> primaryPhoneTypes { get; set; } public List<SelectOption> primaryAddressTypes { get; set; } public List<SelectOption> otherPhoneTypes { get; set; } public List<SelectOption> otherAddressTypes { get; set; } public List<SelectOption> majorCategory { get; set; } public List<SelectOption> secondMajorCategory { get; set; } public List<SelectOption> minorCategory { get; set; } public ProfileSubmitController() { eligibleToWorkUS = new List<SelectOption>(); Schema.DescribeFieldResult fieldResult = Application__c.Eligible_to_work_in_US__c.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { eligibleToWorkUS.add(new SelectOption(f.getLabel(), f.getValue())); } genders = new List<SelectOption>(); genders.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.Gender__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { genders.add(new SelectOption(f.getLabel(), f.getValue())); } ethnicity = new List<SelectOption>(); ethnicity.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.Ethnicity__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { ethnicity.add(new SelectOption(f.getLabel(), f.getValue())); } freeOrReducedLunch = new List<SelectOption>(); fieldResult = Application__c.GAP_Grant_Free_or_Reduced_Lunch__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { freeOrReducedLunch.add(new SelectOption(f.getLabel(), f.getValue())); } grantPellRecipient = new List<SelectOption>(); fieldResult = Application__c.Gap_Pell_Grant_Recipient__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { grantPellRecipient.add(new SelectOption(f.getLabel(), f.getValue())); } parentsHighestEducation = new List<SelectOption>(); fieldResult = Application__c.Parents_Highest_Level_of_education__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { parentsHighestEducation.add(new SelectOption(f.getLabel(), f.getValue())); } Map<String, State_List__c> stateList = State_List__c.getAll(); states = new List<SelectOption>(); states.add(new SelectOption('', 'Please Select...')); List<SelectOption> statesAux = new List<SelectOption>(); for (String stateName : stateList.keySet()){ statesAux.add(new SelectOption(stateList.get(stateName).Abbreviation__c, stateName)); } statesAux.sort(); states.addAll(statesAux); /* collegeList = new List<SelectOption>(); collegeList.add(new SelectOption('', 'Please Select...')); List<Account> sitesList = [SELECT Name FROM Account WHERE RecordType.Name = 'Colleges & Universities']; for (Account acc : sitesList){ if (acc.Name != null){ collegeList.add(new SelectOption(acc.Id, acc.Name)); } } */ primaryPhoneTypes = new List<SelectOption>(); primaryPhoneTypes.add(new SelectOption('', 'Please Select...')); primaryPhoneTypes.add(new SelectOption('Home', 'Home')); primaryPhoneTypes.add(new SelectOption('Cell', 'Cell')); primaryPhoneTypes.add(new SelectOption('Office 1', 'Office')); primaryPhoneTypes.add(new SelectOption('Other', 'Other')); primaryAddressTypes = new List<SelectOption>(); primaryAddressTypes.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.npe01__Primary_Address_Type__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { primaryAddressTypes.add(new SelectOption(f.getLabel(), f.getValue())); } otherPhoneTypes = new List<SelectOption>(); otherPhoneTypes.add(new SelectOption('', 'Please Select...')); otherPhoneTypes.add(new SelectOption('Home', 'Home')); otherPhoneTypes.add(new SelectOption('Cell', 'Cell')); otherPhoneTypes.add(new SelectOption('Office', 'Office')); otherPhoneTypes.add(new SelectOption('Other', 'Other')); otherAddressTypes = new List<SelectOption>(); otherAddressTypes.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.Other_Address_Type__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { otherAddressTypes.add(new SelectOption(f.getLabel(), f.getValue())); } majorCategory = new List<SelectOption>(); majorCategory.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.College_Major_Category_new__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { majorCategory.add(new SelectOption(f.getLabel(), f.getValue())); } secondMajorCategory = new List<SelectOption>(); secondMajorCategory.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.College_Major_Category_2nd_Major__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { secondMajorCategory.add(new SelectOption(f.getLabel(), f.getValue())); } minorCategory = new List<SelectOption>(); minorCategory.add(new SelectOption('', 'Please Select...')); fieldResult = Contact.College_Minor_Category__c.getDescribe(); ple = fieldResult.getPicklistValues(); for (Schema.PicklistEntry f : ple) { minorCategory.add(new SelectOption(f.getLabel(), f.getValue())); } } @RemoteAction public static Boolean savePageOne(String application, String myContact){ List<Breakthrough_Application_Settings__c> settings = [SELECT Name, Regular_Deadline__c, Backdoor_Application_Open__c FROM Breakthrough_Application_Settings__c WHERE Active__c = true LIMIT 1]; Datetime backdoorOpen = Datetime.newInstance(settings[0].Backdoor_Application_Open__c, Time.newInstance(0,0,0,0)); Boolean backdoorApplicationOpen = Datetime.now() >= backdoorOpen; Contact cont = (Contact)JSON.deserialize(myContact, Contact.Class); Application__c app = (Application__c)JSON.deserialize(application, Application__c.Class); if (String.isBlank(cont.College__c) && String.isNotBlank(cont.Other_College__c)){ RecordType collegeRecordType = [SELECT Id FROM RecordType WHERE Name = 'Colleges & Universities']; Account newCollege = new Account(RecordTypeId = collegeRecordType.Id, Name = cont.Other_College__c); insert newCollege; cont.College__c = newCollege.Id; } cont.Other_College__c = ''; update cont; app.Page_1_Status__c = 'Complete'; if (backdoorApplicationOpen) { RecordType recordType = [select Name from RecordType where Name = 'Backdoor' and SObjectType = 'Application__c']; app.RecordTypeId = recordType.Id; app.X2nd_City_Preference__c = null; app.X2nd_City_Housing_Needed__c = null; app.X3rd_City_Preference__c = null; app.X3rd_City_Housing_Needed__c = null; } try { update app; } catch (Exception e) { app.Page_1_Status__c = 'In Progress'; update app; } Datetime regularDeadline = Datetime.newInstance(settings[0].Regular_Deadline__c, Time.newInstance(0,0,0,0)).addDays(1); return ((Datetime.now() >= regularDeadline) && !backdoorApplicationOpen); } @RemoteAction public static List<Result> getSearchResults(String searchTerm) { List<Result> resultsList = new List<Result>(); searchTerm = searchTerm + '*'; List<List<sObject>> searchResults = [FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, Name WHERE RecordType.Name = 'Colleges & Universities')]; if(!searchResults.isEmpty()) { for(List<sObject> objects : searchResults) { for(sObject obj : objects) { Account a = (Account)obj; Result r = new Result(a.Name, a.Id); resultsList.add(r); } } } return resultsList; } public class Result { public String name {get; set;} public String recordId {get; set;} public Result(String name, String recordId) { this.name = name; this.recordId = recordId; } } }
A first change could be:
BillingCity,BillingState and/or City__c, State__c / ShippingCity,ShippingState and so on (according your
Your code is quite big and complicated so the complete validation is not easy.
Regards
All Answers
A first change could be:
BillingCity,BillingState and/or City__c, State__c / ShippingCity,ShippingState and so on (according your
Your code is quite big and complicated so the complete validation is not easy.
Regards