Pardot creates some Tasks for agents to contact a potential customer but the marketing team is saying they cannot set the Related To field to be the Account for the Contact. So I tried setting the Account via a trigger but not getting it to work.
I tried:
trigger TestTaskTrigger on Task (before insert) {
for (Task t : trigger.new){
String c = t.Who.Name;
Id a = [select AccountId from contact where name = :c];
t.What = a;
}
}
This just generates an error of Illegal assignment from List to Id
Looking for suggestions.
t.WhatId
? You also need to move that query outside the loop