You need to sign in to do that
Don't have an account?
Issue with Recordtypes
Hello All,
I am trying to write a trigger for a certain Task record type
But it keeps ignoring the line
Thanks,
Todd B.
I am trying to write a trigger for a certain Task record type
trigger Update_SD_Member_Enrollment_Progress_Status on Task (after update) { /* Automatically update the "Enrollment Progress Status" field, based upon the "Status" field of the last Member Task */ // Tasks that meet criteria, and new tasks to create Task[] qualifiedTasks = new Task[0], newTasks = new Task[0]; Date dt=DateTime.now().addDays(1).date(); Date rt=DateTime.now().addDays(1).date(); // Map of SD Members Map<Id,SD_Member__c> members = new Map<Id,SD_Member__c>(); // Find qualifying tasks for(Task record:Trigger.new) if(Record.RecordType.DeveloperName =='Member Outreach' && record.isclosed == True) qualifiedtasks.add(record); // Obtain member ID values for(Task record:qualifiedtasks) members.put(record.whatid,null); // If there are any members to query, do so. if(!members.isempty()) members.putall([select id, Enrollment_Progress_Status__c from SD_Member__c where id in :members.keyset()]); // For each qualifying task, check the current Enrollment_Progress_Status__c from SD_Member__c and assign // to the strStatus variable. That way if the Task Status does not meet the critera below, the status // will reamin it's current value for(Task record:qualifiedtasks) { String strStatus = members.get(record.whatid).Enrollment_Progress_Status__c; // Set the strStatus based on the current Task Status value If (record.Status == 'Not Started' ){ StrStatus = 'Attempting to Contact';} If (record.Status == 'Left Message w/ Person' ){ StrStatus = 'Successful Contact';} If (record.Status == 'Member Hung Up' ){ StrStatus = 'Successful Contact';} If (record.Status == 'Phone # Invalid' ){ StrStatus = 'Phone # Invalid';} If (record.Status == 'Reached Recording - No Msg Left' ){ StrStatus = 'Attempting to Contact';} If (record.Status == 'Reached Target - Call Later' ){ StrStatus = 'Successful Contact';} If (record.Status == 'Reached Recording - No Msg Left' ){ StrStatus = 'Attempting to Contact';} If (record.Status == 'Reached Target - Call Later' ){ StrStatus = 'Successful Contact';} If (record.Status == 'Reached Target - Declined - Copay' ){ StrStatus = 'Declined - Copay';} If (record.Status == 'Reached Target - Declined - Other' ){ StrStatus = 'Declined - Other';} If (record.Status == 'Reached Target - Declined - Transport' ){ StrStatus = 'Declined - Transportation';} If (record.Status == 'Reached Target - Requested Info' ){ StrStatus = 'Decision Pending';} If (record.Status == 'Reached Target - Sent to Care Coach' ){ StrStatus = 'Referred to Care Coach';} If (record.Status == 'Reached Target - Thinking About It' ){ StrStatus = 'Decision Pending';} SD_Member__C SD1 = new SD_Member__C(ID=record.WhatId,Enrollment_Progress_Status__c=strStatus); update SD1; } }
But it keeps ignoring the line
if(Record.RecordType.DeveloperName =='Member Outreach' &&Any ideas on how to reference the Recordtype in the trigger? I only want this to fire off for one of the five Task recordtypes we have.
Thanks,
Todd B.
We can't get the relationship value inside trigger so you need to get that value from the database prior to move into Trigger.new loop
Add Following line before line 17
add after that your if condition will be
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
All Answers
We can't get the relationship value inside trigger so you need to get that value from the database prior to move into Trigger.new loop
Add Following line before line 17
add after that your if condition will be
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
On I am getting a error on line 17: Method does not exist or incorrect signature: [List<Task>].keyset()
I am sorry for the typo. it is
Thanks,
Himanshu
I have to do away with the .DeveloperName
And just use RecordType.Name instead.