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
Rung41Rung41 

VF Log A Call page with values populated by the RelatedTo

Can anyone point me in the right direction where I could find out how to pass the value of a picklist on the Account object to a similar picklist on VF Log A Call page. I am trying to create a dependent picklist on my VF Log A Call page but have the value predefined by a picklist value on the realted Account page.
Best Answer chosen by Rung41
Rung41Rung41
I take it I place the code within my Extension? 
public with sharing class LogACallControllerExtension {

    public Task task {get; set;}

    public LogACallControllerExtension(ApexPages.StandardController controller) {
            this.task = (Task)controller.getRecord();
            this.task.whatId = ApexPages.currentPage().getParameters().get('what_id');    
            this.task.subject = 'Outside Sales Call';    // or      this.task.subject = ApexPages.currentPage().getParameters().get('tsk5');
            this.task.type = 'Call';
            this.task.status = 'Completed';
            this.task.activitydate = Date.today();
    }
    
    public List<SelectOption> getvalues()
{
  List<SelectOption> options = new List<SelectOption>();
        
 Schema.DescribeFieldResult fieldResult =  Account.Market_Segment__c.getDescribe();
      List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}
}

All Answers

sumit singh 37sumit singh 37
public List<SelectOption> getvalues()
{
  List<SelectOption> options = new List<SelectOption>();
        
 Schema.DescribeFieldResult fieldResult =  Account.PicklistFieldName.getDescribe();
      List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}
Use this code to get the picklist values
 
Rung41Rung41
I take it I place the code within my Extension? 
public with sharing class LogACallControllerExtension {

    public Task task {get; set;}

    public LogACallControllerExtension(ApexPages.StandardController controller) {
            this.task = (Task)controller.getRecord();
            this.task.whatId = ApexPages.currentPage().getParameters().get('what_id');    
            this.task.subject = 'Outside Sales Call';    // or      this.task.subject = ApexPages.currentPage().getParameters().get('tsk5');
            this.task.type = 'Call';
            this.task.status = 'Completed';
            this.task.activitydate = Date.today();
    }
    
    public List<SelectOption> getvalues()
{
  List<SelectOption> options = new List<SelectOption>();
        
 Schema.DescribeFieldResult fieldResult =  Account.Market_Segment__c.getDescribe();
      List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}
}
This was selected as the best answer