I created a custom object named Related_Staff_Positions which is a child lookup to the contact object.
Whenever one saves a new record, in a trigger I wish to get all records in the Related_Staff_Positions object for the given contact and the contact id itself.
Here is my skeleton code that does not work at all. What do I need to modify? Sorry but I am still new at this.
trigger trgr_Related_Staff_Position on Related_Staff_Positions__c (after insert,after update,after delete)
{
// Set<Id> setConID = new Set<Id>();
List<Related_Staff_Positions__c> rsp_List = new List<Related_Staff_Positions__c>();
rsp_LIst = [Select Contact__c , first_name__c, last_name__c from Related_Staff_Positions__c where Contact__c IN: Trigger.New];
<ID> id = trigger.get(contact_c);
if(Trigger.isInsert)
{
for(Related_Staff_Positions__c ct : Trigger.New)
{
ct.Contact__c;
}
}
else if(Trigger.isUpdate)
{
for(Related_Staff_Positions__c ct : Trigger.New)
{
}
}
}
Related_Staff_Positions__c
, then yourtrigger.new
will give you list ofRelated_Staff_Positions__c
; not list of Contacts.