i have problem with a exercise Writing a trigger in Apex that updates the field "location" of the Boat, when the "boat location" field of the associated Contact is modified, for all the boats that are linked to that Contact. The "Location of boat object" field should be the same as the "location of object contact boat
Boat = custom object-------location = (data type : picklist = Argentina,Brasil,España,India)------ field name= Contact, data type=Lookup Relationship
Contact = object standard----- boat_location = (data type : picklist = Argentina,Brasil,España,India)
my code is wrong and I don't know how to fix it
trigger UpdateLocation on Contact (before update) {
if (Trigger.isUpdate) {
List<Contact> cList = new List<Contaact>();
Map<Id,Contact> acctsWithOpps = new Map<Id,Contact>(
[SELECT Id,(SELECT Id FROM Boat) FROM Contact WHERE Id IN :Trigger.New]);
}
}
List<Contact> cList = new List<Opportunity>();
Can aList
ofContacts
ever be aList
ofOpportunities
?