I'm just getting my feet wet in regards to Salesforce in general, but specifically with Apex programming (still an undergraduate student). We added some custom fields to the Activities object that show up on the Task page and I've been looking for a way to populate those, much like how the "Phone" and "Email" field standardly do but I haven't had any success with this. Can anyone point me in the right direction for doing so? An example of one of the fields we'd like to draw information from is Phone_2__c in the Contact object, which I'd like to populate in a custom Activities field of the same name (Phone_2__c)

  • 1
    How are you creating the task? Standard/custom button, VF page etc?
    – Girbot
    May 13, 2015 at 13:21
  • are you asking for a student project? May 13, 2015 at 13:38
  • 1
    Not for a student project. I'm an IT Intern who's learning Salesforce as we implement it at a small IT consulting firm
    – Kyle Walsh
    May 14, 2015 at 14:07

1 Answer 1


There are 3 options to populate fields:

  1. Pre-population via URL hack for Standard Layouts: Sample Video
  2. Pre-population for Visualforce pages: Initialize fields in an apex controller like myActivity.Phone = '12343';.
  3. Populate after submission: Create a trigger before insert:


trigger ANewTrigger on Activity (before insert)
    for(Activity a : trigger.new) a.Phone = '1234';

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .