I need a trigger to update the standard phone field on the task object from the value in the standard Account phone field

Related links https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000BKqIIAW https://developer.salesforce.com/forums/?id=906F0000000D7LVIA0

Using person accounts its not possible through process builder or formula or WFR

New to triggers Should I create a task trigger and query all tasks that have a related Account OR GO THE OTHER WAY AROUND Create the trigger on the Account that queries Account with related Task

OR does it even matter at all


1 Answer 1


You need both. When the phone number changes, you need to update the tasks, and when you create a task, you need to copy the phone number. Without doing both, your phone values will not remain in sync. The Account trigger should only update the tasks when the number changes, and only for tasks that do not have the right number. The task trigger should query the account and copy the phone number. Assuming the phone number field should be just read-only, you can have the task query the accounts each time the task is created or updated, and copy the value.

If you don't need the phone field to be "Click-to-dial" enabled, why not just make a formula field:

  • thanks for this suggestion - This helps a lot . Yes the click to dial is a requirement Cheers Jan 16, 2018 at 22:42
  • How is this first attempt @sfdcfox trigger pushaccountphonefield on task (after insert, after update) { List <Account> accountsWithTasks = [select id, whatid from task where what.type = 'Account' for (Account a: accountsWithTasks) (Task.Phone == Account.Phone) { } } Jan 22, 2018 at 22:53
  • @DerekDolan You'll want to read more about triggers, or try using the Process Builder.
    – sfdcfox
    Jan 22, 2018 at 23:10

You must log in to answer this question.

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