You need to sign in to do that
Don't have an account?

Need help with Trigger test class
Hello Guys, I'm new to Apex Triggers. I need help in writing a test class for the below Trigger. Whenever a platform event message (unique Id) is published from a lightning flow, the trigger updates the Service Appoinmtment record whose Id is the event message. Please let me know if I should make any changes to the trigger.
trigger platformtrigger on Notification__e (after insert) { for(notification__e ev: Trigger.new) { ServiceAppointment SADispatched = [SELECT Id, ParentRecordId FROM ServiceAppointment WHERE Id = :ev.message__c]; SADispatched.description = 'Automate Process'; SADispatched.FSL__Auto_Schedule__c = true; update SADispatched; } }
Below is a snippet that suggests that you cannot refer to :ev.message__c, but must first declare a String variable and assign the value of of ev.message__c to it and then reference it in your SOQL statement.
However, unlike inline SOQL, dynamic SOQL can’t use bind variable fields in the query string. The following example isn’t supported and results in a Variable does not exist error:
You can instead resolve the variable field into a string and use the string in your dynamic SOQL query: