You need to sign in to do that
Don't have an account?
Suresh Raghuram
Creating the same record always
I wrote a trigger to invoke this class, but ths is populating the same record when ever i am creating the new contact
public class createphantom
{
//contact cnt = new contact();
List<contact> cnt=[select Name,id,ReportsToId, AccountId from Contact limit 10];
phantom__c pnt = new phantom__c();
public void phantom() //Method to be invoked by the trigger
{
pnt.Name = 'patient123';
pnt.External_Key__c = cnt[0].Id;
pnt.Last_Name__c = cnt[0].Name;
pnt.Reports_To__c = cnt[0].ReportsToId;
pnt.Account_Name__c = cnt[0].AccountId;
Insert pnt;
}
}
You need to iterate through your list - you're just calling the first index in your list.
-Andy
It is again reading the same old record
If you want to query for just inserted contact, this is not the way to do it. Is that what you want. then user Trigger.new
Tell us exactly what you are trying to do.
trigger on contact obj will invoke this createPhantom class, when a new contact is created and populates the phantom object with few fields of the contact