You need to sign in to do that
Don't have an account?
Rodolfo Rito
How can I put the Task in the correct Lead ?
It's giving me this error :
Thanks!
Help in Trigger with Tasks
trigger TasksonLeads on Lead (after update) { for (Lead l : Trigger.new) { if (l.status == 'Awaiting First Call Attempt' && l.aux_reporting_min_req_mql_tasks__c == false && l.aux_reporting_first_assigned__c == true && l.aux_scoring_first_attempt__c == false && l.min_req_mql_landlord__c == null) { Task Landlord = new Task(); String userId = UserInfo.getUserId(); Landlord.Subject = '1. Is it a landlord?'; Landlord.Priority = 'Normal'; Landlord.Status = 'Open'; Landlord.OwnerId = userId; Landlord.WhatId = l.Id; insert Landlord; } } }
How can I put the Task in the correct Lead ?
It's giving me this error :
Thanks!
Hi,
if you are using after update then i think you have to put trigger.old. Use trigger.new if you are using after insert.
please let me know if this helps.
Thanks,
Manhar
Already tried with after update (and trigger.old) and after insert (and trigger.new).
Hi Rodolfo,
Please try WhoId instead WhatId.
Landlord.WhoId = l.Id;
Thanks,
Manohar
It should work when l.aux_reporting_first_assigned__c turns true.
which event should I use then?
Hi,
Manohar is correct you simply have to replace whoId in place of whatId then its working fine and you also have to ensure that all if conditions get satisfied,
Thanks,
Sagar Lakhani
It is not creating the task!
Hi Rodolfo,
i think you should go with before update.
Thanks,
Manohar
Hi Rodolfo,
Plaese change Trigger.old to Trigger.New then do test its definitely works.
Thanks,
Sagar lakhani
Hi Rodolfo,
you don't need to change after to before you only have to replace trigger.old to trigger.new.
Thanks,
Sagar lakhani
Hi Rodolfo,
This looks like a Recursive Trigger issue. Usually when you have maximum trigger depth exception this means that a trigger is getting recursively fired. You can only have something recursively fire 16 times (Max Stack Depth).
Please go through below link for solution
http://www.infallibletechie.com/2014/05/maximum-trigger-depth-exceeded.html
Thanks,
Sagar Lakhani
Same trigger works for me.
You have to handle recursion.Make a class like below
Please let us know if it works,
Thanks,
Manohar
it didn't give an error but nothing happenned.
You just used Landlord.WhatId = l.Id; instead of Landlord.WhoId = l.Id; and code not bulkified using a list.
Try the code below and add your condition:
Alain
Hi Rodolfo,
Same thing works for me. put debug for your all conditions. I think any one of them is not true.
also put system.debug('p.id:'+p.id); to see if its getting created or not. Let me know if debugging not works.
Thanks,
Manohar
Regards,
Ajay
It's not working.
Here's the last one: