You need to sign in to do that
Don't have an account?
iperez_genius
So this trigger compiles and executes howerver there is a problem with obtaining values.
the red are the values i need and the subject value comes out fine, however the green value is null.
can someone please advise.
I have no idea how to fix my problem. I also need code not just advice. I am on a steep learning curve here, this is my first look at apex code :)
Any help and advice is greatly appreciated.
Ilan
trigger help
Code:
trigger updateLead on Task (after insert)
{
List<Lead> leadsToUpdate = new List<Lead>();
for (Task t: Trigger.new)
{
System.debug('1');
System.debug(t.Subject+'2');// value is mailMerge
System.debug(t.What.Type+'3'); // value is null
if (t.What.Type=='Lead' && t.Subject=='mailMerge')
{
System.debug('4');
Lead l = new Lead(Id = t.WhatId);
if (l.SentInfoPack__c == 'no')
{
System.debug('5');
l.SentInfoPack__c = 'yes';
leadsToUpdate.add(l);
}
}
}
update leadsToUpdate;
}
So this trigger compiles and executes howerver there is a problem with obtaining values.
the red are the values i need and the subject value comes out fine, however the green value is null.
can someone please advise.
I have no idea how to fix my problem. I also need code not just advice. I am on a steep learning curve here, this is my first look at apex code :)
Any help and advice is greatly appreciated.
Ilan
Quick n' dirty workaround: make a String variable equal to WhatId, then check if the first 3 characters are '00Q'. All leads' IDs will start with 00Q.
i.e.
for(Task[] arrTask : ([
Select t.Who.Name, t.Who.Id, t.WhoId, t.What.Name, t.What.Id, t.WhatId
From Task t
]))
{
for(Task sTask : arrTask)
{
// do your processing
}
}
Hope that's what you were looking for.
Sorry, you will also need:
// this will retrieve all Tasks and the extended relationship information for all tasks within the trigger
for(Task[] arrTask : ([
Select t.Who.Name, t.Who.Id, t.WhoId, t.What.Name, t.What.Id, t.WhatId
From Task t
Where id in trigger.newMap.keySet()
]))
{
for(Task sTask : arrTask)
{
// do your processing
}
}