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
Linda Gatson 7Linda Gatson 7 

Need to figure out where/how to edit picklist on a visualforce page


<apex:selectOptions value="{!generalActivityOptions}"/>

This is what our former developer said: So apparently the Time Entry page was written in Visualforce. The backend code builds those drop down lists in code and looks at a Custom Setting in Salesforce to build the options in the picklist. So editing the picklist does nothing towards changing the values you see in the Activity dropdown list on the Daily Time Entry page.  
Martha VMartha V
The options are written in the controller or controller extension for the Visualforce page. To find out the name of the apex class look at the top of your Visualfor page, on the <apex:page .... > there should be either an attribulte that says controller="xxxx"  or one that says extensions="xxxx"
where xxxx is the name of the apex class used as the controller or controller extension for the page.
Linda Gatson 7Linda Gatson 7
Thanks for your reply Martha. I see <apex:page title="Daily Timesheet" standardController="Timesheet__c" extensions="TimesheetExtension" sidebar="false" action="{!navigate}" tabStyle="timesheet__tab">

I found and looked at an apex class page called TimesheetExtension, but still don't see the picklist items I need to edit. Any other thoughts?
Martha VMartha V
Maybe if you paste the visualforce page code here as well as your apex class code. It could be a custom setting or in another object if you don't see it in the code.
Linda Gatson 7Linda Gatson 7
Thanks again Martha, This is the code from our VF page: .modified { color: rgb(255, 106, 0); font-weight: bold; }  



Total for Day Note: Project choices cannot be edited once saved. To remove a time entry, highlight and delete Labor and Travel hours on that row and click Save. And this is the code from the TimesheetExtension page: public with sharing class TimesheetExtension { public Timesheet__c timesheet; public Contact userContact; List upserts = new List(); List deletes = new List(); private Date currentDate; public Boolean dirty {get; set;} public class ProjDescException extends Exception{} /* * */ public TimesheetExtension(ApexPages.standardController ctl) { this.timesheet = (timesheet__c)ctl.getRecord(); dirty = false; if (getUserContact() == null) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Timesheets can only be created for users with matching Contact records. Please see your system administrator for assistance.')); } Schema.sobjecttype.Timesheet__c.getKeyPrefix(); } public void pageDirty() { this.dirty = true; } public Boolean getValidUser() { return (getUserContact() != null); } /* * */ public PageReference navigate() { if (timesheet.id == null) { timesheet.status__c = 'New'; try { timesheet.person__c = getUserContact().id; timesheet.person__r = getUserContact(); } catch (Exception e) { } String dateParam = ApexPages.currentPage().getParameters().get('dt'); if (dateParam != null) { currentDate = Date.valueOf(dateParam); } else { currentDate = System.today(); } timesheet.workday__c = currentDate; try { Timesheet__c findTimesheet = [SELECT ID, Status__c FROM timesheet__c WHERE person__c = :timesheet.person__c AND workday__c = :currentDate LIMIT 1]; if (findTimesheet.id != null) { return new ApexPages.standardController(findTimesheet).edit(); } } catch (Exception e) { } } else { if (timesheet.status__c == null) timesheet.status__c = 'New'; } return null; } public Contact getUserContact() { if (userContact == null) { String uId = Userinfo.getUserId(); try { userContact = [SELECT ID, name FROM contact WHERE user_account_link__c = :uId LIMIT 1]; } catch(Exception e) { } } return userContact; } /* * */ public Boolean getIsLocked() { //return (timesheet.status__c != 'New'); if (timesheet.id == null || timesheet.Weekly_Timesheet__c == null) { return false; } else { return (timesheet.week_status__c != 'New'); } } /* * */ public PageReference switchDate() { Timesheet__c tm = new Timesheet__c(); PageReference pg = Page.DailyTimesheet; Date dt = timesheet.Workday__c; pg.getParameters().put('dt',dt.year() + '-'+dt.month() + '-' + dt.day()); pg.setRedirect(true); return pg; //return null; } public PageReference nextDay() { Timesheet__c tm = new Timesheet__c(); if (timesheet.Workday__c != null) { PageReference pg = Page.DailyTimesheet; Date dt = timesheet.workday__c.addDays(1); pg.getParameters().put('dt',dt.year() + '-'+dt.month() + '-' + dt.day()); pg.setRedirect(true); return pg; } else { return null; } } public PageReference prevDay() { Timesheet__c tm = new Timesheet__c(); if (timesheet.Workday__c != null) { PageReference pg = Page.DailyTimesheet; Date dt = timesheet.workday__c.addDays(-1); pg.getParameters().put('dt',dt.year() + '-'+dt.month() + '-' + dt.day()); pg.setRedirect(true); return pg; } else { return null; } } /* * */ public List projectEntries { get { if (projectEntries == null) { projectEntries = getEntries(Utility.RT_TIME_PROJECT.id); } return projectEntries; } set; } public Boolean hasProjectEntries { get { return projectEntries != null && projectEntries.size() > 0; } } /* * */ public List oppEntries { get { if (oppEntries == null) { oppEntries = getEntries(Utility.RT_TIME_OPPORTUNITY.id); } return oppEntries; } set; } public Boolean hasOppEntries { get { return oppEntries != null && oppEntries.size() > 0; } } /* * */ public List accEntries { get { if (accEntries == null) { accEntries = getEntries(Utility.RT_TIME_ACCOUNT.id); } return accEntries; } set; } public Boolean hasAccountEntries { get { return accEntries != null && accEntries.size() > 0; } } /* * */ public List otherEntries { get { if (otherEntries == null) { otherEntries = getEntries(Utility.RT_TIME_OTHER.id); } return otherEntries; } set; } public Boolean hasOtherEntries { get { return otherEntries != null && otherEntries.size() > 0; } } /* * */ private List getEntries(ID rtId) { List entries = [SELECT ID , name , account__c , activity__c , opportunity__c , project__c , service_hours__c , travel_hours__c , total_hours__c , description__c , recordTypeId , Activity_Link__c FROM Time_Entry__c WHERE timesheet__c = :timesheet.id AND RecordTypeId = :rtId]; if (rtId == Utility.RT_TIME_OTHER.id && getIsLocked() == false) { for (Integer i = 0; i < 3; i++) { entries.add(new Time_Entry__c(RecordTypeId=rtId, Workdate__c = currentDate, Contact__c=userContact.Id)); } } else if (entries.isEmpty()) { for (Integer i = 0; i < 1; i++) { //entries.add(new Time_Entry__c(RecordTypeId=rtId)); } } return entries; } /* * */ public List allEntries { get { if (allEntries == null) { allEntries = [SELECT ID , name , account__c , activity__c , opportunity__c , project__c , service_hours__c , travel_hours__c , total_hours__c , description__c , recordTypeId , title__c FROM Time_Entry__c WHERE timesheet__c = :timesheet.id ORDER BY recordTypeId , project__c]; } return allEntries; } set; } /* * public List getProjects() { Map projectMap = new Map(); List projects = new List(); Date endDateRange = timesheet.Workday__c - 120; List prs = [SELECT project__c , project__r.id , project__r.name FROM project_resource__c WHERE resource__c = :getUserContact().id AND project__r.start_date__c = :endDateRange OR project__r.actual_Completion__c = null) //AND project__r.status__c NOT IN ('Cancelled') ORDER BY project__r.name]; for (Project_Resource__c pr : prs) { if (projectMap.get(pr.project__c) == null) { projectMap.put(pr.project__c, pr.project__r); projects.add(pr.project__r); } } return projects; } */ /* * public List getProjectOptions() { if (projectOptions == null) { projectOptions = new List(); projectOptions.add(new SelectOption('', '')); for (Project__c p : getProjects()) { projectOptions.add(new SelectOption(p.id, p.name)); } } return projectOptions; } */ /* * public List getProjectActivityOptions() { if (projectActivityOptions == null) { projectActivityOptions = getActivityOptions(Utility.RT_TIME_PROJECT.id); } return projectActivityOptions; } */ /* * public List getOpportunityActivityOptions() { if (opportunityActivityOptions == null) { opportunityActivityOptions = getActivityOptions(Utility.RT_TIME_OPPORTUNITY.id); } return opportunityActivityOptions; } */ /* * public List getAccountActivityOptions() { if (accountActivityOptions == null) { accountActivityOptions = getActivityOptions(Utility.RT_TIME_ACCOUNT.id); } return accountActivityOptions; } */ /* * */ public List generalActivityOptions { get { if (generalActivityOptions == null) { generalActivityOptions = getActivityOptions(Utility.RT_TIME_OTHER.id); } return generalActivityOptions; } private set; } /* * */ public List getActivityOptions(ID rtId) { List opts = new List(); opts.add(new SelectOption('', '')); for (String act : Utility.getActivityList(rtId)) { opts.add(new SelectOption(act, act)); } return opts; } /* * */ public List summary { get { if (summary == null) { summary = new List(); summary.add(timesheet); } return summary; } set; } /* * */ private void updateEntries(List entries) { for (Time_Entry__c te : entries) { if (te.id != null && te.Service_Hours__c == null && te.Travel_Hours__c == null) { deletes.add(te); } else if (te.Service_Hours__c != null) { if (te.id == null) { te.Workdate__c=timesheet.Workday__c; te.Contact__c = userContact.ID; te.Timesheet__c = timesheet.ID; } upserts.add(te); } } } /* * */ private void saveChanges() { if (dirty != null && dirty == true) { //only do the save if something has changed if (timesheet.ID == null) { timesheet = TimeEntryUtility.buildTimesheet(timesheet.Workday__c, userContact.ID); } upserts = new List(); updateEntries(projectEntries); updateEntries(oppEntries); updateEntries(accEntries); updateEntries(otherEntries); upsert upserts; if (deletes.size() > 0) { delete deletes; } } } /* * */ public PageReference submitTimesheet() { try { if (getIsLocked() == false) { //don't save changes if we're locked saveChanges(); } } catch (Exception e) { ApexPages.addMessages(e); return null; } Weekly_timesheet__c wt = new Weekly_Timesheet__c(ID=timesheet.Weekly_Timesheet__c); return new ApexPages.standardController(wt).view(); } /* * */ public PageReference saveTimesheet() { String projDescCheck = ''; if (dirty != null && dirty == true) { try { //projDescCheck = getCheckProjects(); //if(projDescCheck == '') { saveChanges(); //} else { // if(Label.EnableProjectDescValidation == 'Y') { // throw new ProjDescException(projDescCheck); // } //} } catch (Exception e) { ApexPages.addMessages(e); return null; } return new ApexPages.standardController(timesheet).edit(); } else { return null; } } public PageReference cancelSave() { PageReference ref = ApexPages.currentPage(); ref.setRedirect(true); return ref; } /* public String getCheckProjects(){ String errorstring = ''; Set setProjIds = new Set(); for (Time_Entry__c te:getProjectEntries()) { setProjIds.add(te.Project__c); } for(Project__c pj:[select id, Project_Description__c, Owner.Name, Name from Project__c where id in :setProjIds]) { if(pj.Project_Description__c.length() < 50) { errorstring = errorstring + 'Project Description is invalid for Project: ' + pj.Name + '. Please contact the Project Owner: ' + pj.Owner.Name + ' to request a correction before you may enter your time against this project.' + '\n'; } } System.Debug('error string: ' + errorstring); // return errorstring; } */ }
Martha VMartha V
Sorry, I ran out of time now to look at this. If it hasn't been answered in a few hours I will go through it. However, i read your first post again and it says there that the developer told you that the picklist values are in the Custom Settings. 

If yiu go to Setup and typecustom settings on the search box then click on the custom settings link it will give you a list of all the custom settings In your org. See if you can find one that has a name or description for the Activity in the time sheet. Click on the name to see the values it contains. 

Like i said, I will check on this later and if you haven't found it by then I will see what I can do. 
Martha VMartha V
Try looking for RT_TIME_OTHER in Custom Settings. 
Linda Gatson 7Linda Gatson 7
Yes, we already tried that and checked the links and found nothing that helps. [cid:image001.png@01D2C8B7.DD9C63F0]
Linda Gatson 7Linda Gatson 7
Just replied to your previous message with a screen shot of our custom settings…no RT_TIME_OTHER showing
Martha VMartha V
Sorry Linda, that picture didn't come through.
Linda Gatson 7Linda Gatson 7
Well, it was just a picture of what is showing in our custom setting so that you could see there is no RT_Other_Time. I do think that is what I need to find to made my edits as I see it referenced in all the timecard codes but I’ve checked every VF page and apex class and can’t find it anywhere!
Martha VMartha V
Here are the two methods that get the values for the generalActivityOptions variable:

  public List generalActivityOptions 
  { get 
  { if (generalActivityOptions == null) 
    { generalActivityOptions = getActivityOptions(Utility.RT_TIME_OTHER.id); 
    } 
    return generalActivityOptions; 
  } 
  private set; } /* * */

  public List getActivityOptions(ID rtId) 
  { 
    List opts = new List(); 
    opts.add(new SelectOption('', '')); 
    for (String act : Utility.getActivityList(rtId)) 
    { 
      opts.add(new SelectOption(act, act)); 
    } return opts; 
  } /* * */ 

So my other suggestion is to look into the Custom Settings and see if you find there a custom setting named Utility. If it is there, it should have a field called RT_TIME_OTHER which should be the list of the values for the picklist.

I am out of my depth here, so if this is not the answer I don't think I can't help.
Linda Gatson 7Linda Gatson 7
Thanks! Utility is not found in custom settings, but I did find an apex class called utility. This is the code below. Thanks for trying to help me! I do understand that you said you can’t help anymore. public class Utility { public static RecordType RT_TIME_PROJECT = [SELECT ID, name FROM RecordType WHERE DeveloperName = 'Project' AND sObjectType = 'Time_Entry__c' LIMIT 1]; public static RecordType RT_TIME_OPPORTUNITY = [SELECT ID, name FROM RecordType WHERE DeveloperName = 'Opportunity_Management' AND sObjectType = 'Time_Entry__c' LIMIT 1]; public static RecordType RT_TIME_ACCOUNT = [SELECT ID, name FROM RecordType WHERE DeveloperName = 'Account_Management' AND sObjectType = 'Time_Entry__c' LIMIT 1]; public static RecordType RT_TIME_OTHER = [SELECT ID, name FROM RecordType WHERE DeveloperName = 'Other_Time' AND sObjectType = 'Time_Entry__c' LIMIT 1]; public static RecordType RT_PROPOSAL_DRAFT = [SELECT ID, name FROM RecordType WHERE DeveloperName = 'Draft_Proposal' AND sObjectType = 'Proposal__c' LIMIT 1]; public static String OPPORTUNITY_RESOURCE_ROLES='Internal Delivery|External Delivery|Project Manager'; public static String practiceAreaToNISTSubstance(String practiceArea) { try { Practice_Area_NIST_Substance_Map__c mapEntry = [SELECT Practice_Area__c, NIST_Substance__c, NIST_Code__c FROM Practice_Area_NIST_Substance_Map__c WHERE Practice_Area__c = :practiceArea LIMIT 1]; return mapEntry.NIST_Substance__c; } catch (Exception notFound) { return null; } } public static List getActivityList(ID rtId) { Project_Settings__c ps = Project_Settings__c.getInstance(); String values = ''; if (rtId == RT_TIME_PROJECT.id) { values = ps.project_activities__c; } else if (rtId == RT_TIME_OPPORTUNITY.id) { values = ps.opportunity_activities__c; } else if (rtId == RT_TIME_ACCOUNT.id) { values = ps.account_activities__c; } else { values = ps.general_activities__c; } values = values.replaceAll('\n', '::'); values = values.replaceAll('\r', ''); System.debug('VALUES:' + values); List rows = values.split('::'); System.debug('ROWS:' + rows); return rows; } public static testMethod void testUtility() { Utility.practiceAreaToNISTSubstance('Advanced Talent Management'); Utility.getActivityList(RT_TIME_PROJECT.id); Utility.getActivityList(RT_TIME_OPPORTUNITY.id); Utility.getActivityList(RT_TIME_ACCOUNT.id); Utility.getActivityList(RT_TIME_OTHER.id); }
Martha VMartha V
Oh yeah, I forgot about that option that it could be a class. I will read this class and see if I can figure it out.
Martha VMartha V
Wow!  This is a good learning experience for any developer... we really need to document better!
ok IF i understand correctly, the Utility Class sets the value of RT_TIME_OTHER by giving it the ID of the record type 'Other_Time' in the Object Time_Entry__c

then with the id of that recordtype it calls a class, object or custom setting called Project_Settings__c  project settings has the list of values in a field (or attribute) called general_activities__c

so now check and see if you have an object, class or Custom Setting with the name Project_Settings__c​    I sure hope it is a custom object or a Custom Setting.
Linda Gatson 7Linda Gatson 7
Well, I did find a custom setting named project settings with these fields Custom Fields Action Field Label API Name Data Type Indexed Modified By Edit | Del Account Activities Account_Activities__c Text Area(255) System Administrator, 4/1/2010 7:03 AM Edit | Del Account Management Project Account_Management_Project__c Text(18) System Administrator, 4/1/2010 7:03 AM Edit | Del General Activities General_Activities__c Text Area(255) System Administrator, 4/1/2010 7:03 AM Edit | Del Opportunity Activities Opportunity_Activities__c Text Area(255) System Administrator, 4/1/2010 7:03 AM Edit | Del Opportunity Management Project Opportunity_Management_Project__c Text(18) System Administrator, 4/1/2010 7:03 AM Edit | Del Project Activities Project_Activities__c Text Area(255) System Administrator, 4/1/2010 7:03 AM Edit | Del Weekly Utilization Hours Weekly_Utilization_Hours__c Number(2, 0) System Administrator, 6/3/2010 9:37 AM Edit | Del WMEP Internal Project WMEP_Internal_Project__c Text(18) System Administrator, 4/1/2010 7:03 AM But, I am not looking to update the picklist on Projects, I’m looking to update the other time picklist but do not see any custom setting that has anything to do with that. My boss has contacted our former developer and he is going to get us the answer, but thanks so much for your help. Linda
Martha VMartha V
Make sure to get him to tell you exactly where to change those values :)
Linda Gatson 7Linda Gatson 7
Oh yeah, you better believe I’m documenting this! Thanks again for all your help!