Reading Can you use generics in Apex? generics are supported in apex. When I attempt to run the below trigger in developer console:
trigger TotalTriggerAccount on Account (after update) {
System.debug('Updating account');
String accountId = ApexPages.currentPage().getParameters().get('id');
List<Contact> allContacts = [
SELECT
*
FROM
Contact
WHERE
AccountId = :accountId
];
for (Contact contact : allContacts) {
System.debug(contact.Phone);
}
}
to access all contacts for a given account I receive multiple Problems related to the use of generics and the declaration of the array such as:
Unexpected token '<'.
Unexpected token '>'.
Unexpected token ']'.
Is there a stop required in order to use generics and array elements in apex for developer console ?
Update:
By developer console, I refer to:
To add a new trigger from the developer console:
SELECT *
. Apex/SOQL doesn't allow wildcard field definition. You need to specify each and every field you want to pull. I'd suggest going through some developer-focused modules on trailhead.salesforce.com to help you get your bearings in Apex.ApexPages.currentPage().getParameters().get('id');
inside of a trigger (fetching page parameters is typically used when you're writing a controller or controller extension for a Visualforce page). This is turning into an X-Y problem, I think.