You need to sign in to do that
Don't have an account?
Ian Wright 3
Create a case comment when another object field is not Null
Hi,
I'm new to Apex and am looking to create an auto-generated approval note on the case attached to the custom object Event_Resolution__c. Below is what I have and I keep getting line 5, loop variable must be of Type Question. I assume it means it thinks Case is not defined or related to the event resolution. The case is entered in a lookup field case__c but it says that variable doesn't exist.
Any help on how to make this possible? Basically if anyone on the event resolutions team approves a credit or point value, I want a case comment to automatically populate on the case.
I'm new to Apex and am looking to create an auto-generated approval note on the case attached to the custom object Event_Resolution__c. Below is what I have and I keep getting line 5, loop variable must be of Type Question. I assume it means it thinks Case is not defined or related to the event resolution. The case is entered in a lookup field case__c but it says that variable doesn't exist.
Any help on how to make this possible? Basically if anyone on the event resolutions team approves a credit or point value, I want a case comment to automatically populate on the case.
I have updated the code to check condition for Question record type. I am hoping that Question record type is present on Event Resolution object. Let me know if it is otherwise. Thanks.
New utility class that you need to create first:
Updated trigger code that makes use of this utility class:
All Answers
Your trigger should be on below lines. I have given the sample code, you can extend it further easily. Let me know if you face any issues. Thanks.
This helps a bunch thank you. After extending the code to include everything I needed I now get the error that "Compile Error: Invalid type: Event_Resolution__c.RecordType.Question at line 5 column 9" where if I just leave it as Event_Resolution__c it says that the loop must be of type Question.
I need to make sure the trigger is specific to the record type Question and not just the overall object Event Resolution. Any idea what I'm missing? I can probably just have it be for all records on the object but would prefer it be specific to the record type for more accurate usage by employees.
I have updated the code to check condition for Question record type. I am hoping that Question record type is present on Event Resolution object. Let me know if it is otherwise. Thanks.
New utility class that you need to create first:
Updated trigger code that makes use of this utility class: