Our business is Project-based. The Campaign object has been renamed Project and we use the Project Code (aka: Campaign.Name) as the key index for all records to relate them to the particular project.

Now that SalesForce has allowed custom Lookup fields on Activities, we are able to link Activities to their respective Projects. This works great on Calls, where the Sales rep just inserts the correct Project Code into the field and saves the Activity.

However, on email sends, particularly template sends, there is no way to insert this value into the Activity History record at the time of sending. The email must be sent, then the salesperson has to go back into the Activity History record they just created and enter the Project Code - a required field on manual edit, but not enforced using SalesForce's email send page.

My question is, how can I extract the Project Code from Opportunity and automatically insert it into any emails that are sent from that Opportunity, such that when the salesperson sends the email, the resulting Activity History record campaign lookup field "Project Code" contains the name of the Project Code to which the Opportunity is assigned?

You can't seem to edit any of the Email layouts. I've looked at this problem for ages and I'm hoping someone has a fix. Thanks in advance!

  • You can write triggers for Tasks and all emails are stored as Tasks. Can you write a trigger, and pre-populate the needed values? – singularity Feb 24 '15 at 17:40
  • @singularity: possibly better call it post-populate instead pre-populate – Uwe Heim Feb 24 '15 at 18:42
  • Sorry, I meant pre-populate to indicate "before insert" trigger of the task. Yes, it is post-populate if you consider from email sending point of view. – singularity Feb 24 '15 at 18:43

You could write a Trigger for Task as @singularity suggested. On Task you have a field called WhatId.

I would check if it points to an Opportunity - maybe also you can check for a Task type or record-type, but this depends on your configuration.

If you find in WhatId a valid Opportunity Id you can query on for the Campaign (project) Id, which you can store in the Task. Doing it with a "before insert" Trigger, it would be there in the moment of record-creation. Only from the UI perspective it would be a post-population, since the field will be empty until save (send).

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.