You need to sign in to do that
Don't have an account?
Angie Yzaguirre
trigger to change task record type created by workflow rule
I have created a WFR that creates a task every time the Account has a certain product listed in a custom field. The task is created just fine, but I need the task to be a certain task record type, rather than the default type.
I have created another rule to update the task record type field when the subject correlates to the first task created. I realize that a workflow cannot be triggered off of another workflow.
I need to write the trigger to change the task record type, can someone please help with this??
Thanks!!
I have created another rule to update the task record type field when the subject correlates to the first task created. I realize that a workflow cannot be triggered off of another workflow.
I need to write the trigger to change the task record type, can someone please help with this??
Thanks!!
If you do not name your Apex Trigger as TaskRecordType you have to change in the code with the name that you gave it. Let me know if it worked.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
What will be the criteria to distinguish this Task that want to change the RecordType from another one?
Regards.
Try the code below changing the bolded parts:
taskRecordTypes.get('My Task Name (NOT API)').getRecordTypeId();
In the line above you have to change 'My Task Name (NOT API)' to your RecordType's name (the label) not the API.
if(tsk.Subject.equals('Condition'))
In the line above you should add a condition to prevent your trigger from changing the RecordType of your Tasks even if its not related to that specific case.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
The default task that is created from the first workflow has a subject of CA - NWC Roadmap, I'm assigning it to a member of the Account Team with a Status of Not Started and Priority High (these are the only fields I can automate when creating the task from the workflow). The task record type is default 'Sales - Tasks'.
For the second workflow, the criteria that I want to change is the task record type, from 'Sales - Tasks' to 'CA - NWC Roadmap'.
Please let me know if you need a snapshot or more info on what I'm trying to accomplish. I'm stuck and very new to Apex so it's a bit over my head. Thanks!
If you do not name your Apex Trigger as TaskRecordType you have to change in the code with the name that you gave it. Let me know if it worked.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Just create a class as the code below and deploy it with your trigger:
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
I have a question for you, I see the trigger and test class above. Is there any way you can help me with building an Apex class that would be called by the trigger? I want the apex class to run the recordtype change instead of the trigger. I am in the early stages of learning to write these and would love some assistance.