You need to sign in to do that
Don't have an account?
Melissa Parker
Task record type same as parent record type
Can anyone assist me on how to create a trigger to upate the Task record type to reflect the same as the Parent Record type? For instance, if the Lead or Opporunity record type is "TEST RECORD TYPE" then Task record type is updated as the same "TEST RECORD TYPE". Thanks.
My bad! Lead and Opportunity has different fields in Task so I had to add some extra validations. Please, try the code below:
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
Do you have these record types with the same Labels in all objects? I asking because RecordTypes are exclusive from one object and cannot be share. One solution would be having your RecordTypes with the same Labels. Are you looking for a solution only for Lead and Opportunity or a more generic one?
Regards
SolarPerks
Standard Products
Both have the same lables. Thanks, Zuinglio!
Keep in mind that the code below can be changed as needed and that you must ensure that you have in Task, record types with the same Opp and Lead record types labels.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Do you mean in the code? If so, there is no need to do that, the code itself will handle to get the record type names of Lead and Opportunity and based on that will search for a record type in Task with the same Label.
i.E: If you insert or update a Task related to a Lead, the trigger, based on Lead Id's will search for the record type name of Lead's record. Once found, it will get the name and search for a record type in Task with the same name and then it will get the recordtype's Id and set Task's record with the proper RecordTypeId. That is why you have to ensure that Task also will have two Record Types with the labels SolarPerks and Standard Products as Lead and Opportunity does.
I have put some extra validation in the code to avoid errors:
If you need any further assistance, please let me know. You have to creat the trigger under Task, in the code I named it (first line) TaskRecordType. If you want to give another name just remember to change in the code too.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
It worked?
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
FYI>Thanks again, Zuinglio, for your time and assistance with this! :)
My bad! Lead and Opportunity has different fields in Task so I had to add some extra validations. Please, try the code below:
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
**TO QUOTE ICE CUBE... "TODAY WAS A GOOD DAY"!!**
Thanks!