3

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 '15 at 13:21
  • are you asking for a student project? – Christian Deckert May 13 '15 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 '15 at 14:07
2

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:

code:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.