You need to sign in to do that
Don't have an account?
iperez_genius
complete newbie --> needs a simple trigger
I know its completely slack on my behalf not to have searched through all the posts to find my solution but i am in a bind with time, and i think this will be quicker. Hopefully someone is kind enough to help me.
The situatioin:
A lead comes in, we complete a mail merge and against their name a completed task is created stating a mail merge has been inacted.
I need to create a trigger that updates a custom field (sentPack) in a Lead from default value "no" to "yes"
i am not sure how to do this.
can anyone help me. Please this is urgent
thanks in advance
regards
Ilan Perez
The situatioin:
A lead comes in, we complete a mail merge and against their name a completed task is created stating a mail merge has been inacted.
I need to create a trigger that updates a custom field (sentPack) in a Lead from default value "no" to "yes"
i am not sure how to do this.
can anyone help me. Please this is urgent
thanks in advance
regards
Ilan Perez
This sounds more like a job for a workflow field update or an Scontrol than for a trigger.
I will re-iterate the process.
Leads come in every week.
Each friday a mail merge is created to all new leads or all leads that have not been sent a welcome pack.
Once the mail merge is created a completed task is added onto every lead in the mail merge stating they (the lead) have been included in a mail merge.
What i need is:
based on the the completed task i need to set a custoim field called "Sent Info pack" from no to yes.
Thats hwat i need help with...
thanks in advance
ilan
I know this is not correct because it doesn't work, but its a start from my end.
can anyone help me?
ilan
What you need to do is as follows (some pseudocode here):
Basically, if the tasks pertain to leads, then update the fields on those leads.
werewolf this is my attempt at the code.
the error i am getting is
Error: Compile Error: Loop variable must be of type SOBJECT:Lead at line 4 column 15
...besides the fact that i am not too sure wether this will actually do what i want.
I suppose i dont understand how salesforce loads the values of the leads into arrays...in anycase this for anothe day.
back to the trigger can you advise further
What it's complaining about is you're doing a for (Task t : Trigger.new), but you've set your trigger on Lead so it thinks Trigger.new is going to contain a bunch of Leads. What you really want it to contain is a bunch of Tasks.
Hows this?
the error i am getting is...
Error: Compile Error: Incorrect SObject type: Task should be Lead at line 1 column 1
I am not sure waht to do?
my mistake seems to be that i tried to save the trigger under leads > triggers rather than task > triggers.
so it now compiles fine but it doesn't work :(
i have checked all the field names to make sure the are correct but the trigger still doesn't work
here is the code once again
werewolf we are so close,
Try turning on the debug log when you run this, that will help you figure out where it's exiting.
i have a lead,
i simply create a task on that lead with subject
"mail Merge"
results --> task gets created fine but no field update :(
t.What.Type is null
that piece of code is not working...
i am not sure why though
No idea why this is not working...
is there any way of printing into the log the a field from each lead.
can i give you access to my account for you to check out that its setup correctly?
I really need to sort this out :(
Look forward to your reply
ilan
werewolf
I re-wrote the code and here is my solution...i am not sure how efficient it is, and i am awaiting on salesforce in activate mas mail merge so that i can do a final test but it seems to work when i create a task that has the subject "mailMerge266" and that the task has a whoid of type lead
Thanks for your help
Ilan
Go back to the trigger you had a few iterations ago, with just a quick modification it should work OK:
trying to work through the issues,
like the what.type issue