You need to sign in to do that
Don't have an account?
Trigger to update Task custom field
I have a Workflow rule that creates a Task each time a specific type of Lead is created. I have a custom field in this Task that needs to be populated upon creation but I cannot accomplish this with the Workflow so I am creating a trigger.
I get the following error when I save the trigger
Error: Compile Error: unexpected token: '}' at line 5 column 12
Here is the trigger
trigger PubProductUpdate on Task (before insert){
for (Task PU : Trigger.new){
if (PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
}
{
PU.Pub_Products__c = 'Pub Opening Pitch';
}
}
I am new to Apex Triggers and not sure where my select criteria goes wrong.
Thanks.
= is used for assignment. == is used for comparison.
if(PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
needs to be...
if(PU.RecordTypeId == '012U0000000Z6qBIAS' && PU.Subject == 'Pitch Networks' && PU.Pub_Products__c == null)
All Answers
the "}" on line 5 is closing out your if statement. try this
trigger PubProductUpdate on Task (before insert){
for (Task PU : Trigger.new){
if(PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
{
PU.Pub_Products__c = 'Pub Opening Pitch';
}
}
}
Dave T,
Thanks for the quick response. I made the change and I now get the following error.
Error: Compile Error: AND operator can only be applied to Boolean expressions at line 4 column 54
Steve
= is used for assignment. == is used for comparison.
if(PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
needs to be...
if(PU.RecordTypeId == '012U0000000Z6qBIAS' && PU.Subject == 'Pitch Networks' && PU.Pub_Products__c == null)
Andrew,
That did it for me. Thanks for your help.
Steve