You need to sign in to do that
Don't have an account?

Trying to update Task custom field when a new task is created or updated.
Hi there,
This is my code, and I am only trying to make a Trigger that will update/insert the value TSK in the Type_Task field each time a new task is created or updated.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
trigger UpdateTaskType on Task (before insert, before update) {
for (Task ta:trigger.new)
{
if(ta.Type_Task1__c != 'TSK'){
ta.Type_Task1__c == 'TSK');
}
}
}
//////////////////////////////////////
I have created this using Eclipse but it show red cross, which means there is an error with the code. Can some one advice how to get this working?
Thanks
trigger UpdateTaskType on Task (before insert, before update) {
for (Task ta:trigger.new) {
if(ta.Type_Task1__c != 'TSK') {
ta.Type_Task1__c = 'TSK';
}
}
}
All Answers
Well, you have an extra, unneeded parenthesis in your code:
ta.Type_Task1__c == 'TSK');
You know, Eclipse has a view called Problems which will point you to the precise spot that is generating the error.
hi,
I tried this...still no luck. The eclipse still shows the little red cross on the left and is not saving the trigger on the DEV box.
\\\\\\\\\\\\\\\\\\\\\\
trigger UpdateTaskType on Task (before insert, before update) {
for (Task ta:trigger.new)
{
if(ta.Type_Task1__c != 'TSK')
{
ta.Type_Task1__c == 'TSK';
}// this is for the IF loop
}// this is the FOR loop
}// Ends the trigger
//////////////////////////
Any more ideas???
trigger UpdateTaskType on Task (before insert, before update) {
for (Task ta:trigger.new) {
if(ta.Type_Task1__c != 'TSK') {
ta.Type_Task1__c = 'TSK';
}
}
}
Oh yeah, as Joe points out, you're also using an == where you should be using an =.
ta.Type_Task1__c = 'TSK';