You need to sign in to do that
Don't have an account?
Link Account to a Contact using trigger?
trigger AddAccount on Contact (before insert)
{
for (Contact c:Trigger.new )
{
Account a= new Account();
a.Name='ACME';
a.ID=c.AccountID;
insert a;
}
}
how can i link a Account to a contact ??
{
for (Contact c:Trigger.new )
{
Account a= new Account();
a.Name='ACME';
a.ID=c.AccountID;
insert a;
}
}
how can i link a Account to a contact ??
Just add c.AccountId = a.Id after insert a;
Regards,
Vivek Patel.
trigger AddAccount on Contact (before insert)
{
for (Contact c:Trigger.new )
{
c.AccountId = the account id you want to relate it to // this would ideally be coming from some logic otherwise you need not write this trigger
}
}