You need to sign in to do that
Don't have an account?
Pbondalapati
assign the account if contact is created with out account if account name is abc
assign the account if contact is created with out account if account name is abc ,
i created the trigger , but i account abc is deleted , so how can i manage that .
i want to put a rule that , if contact is created without account , then the contacts aaccount is 'abc'.
if abc is deleted then no account is assigned to that contacts.
Account a = [Select Id from Account where Id='001M0000007VNAe' limit 1];
for(Contact c :trigger.new){
if(a != null){
if(trigger.new[0].accountid == null){
system.debug('>>> Selected Id - '+a.Id);
Contact unAssignedCon = trigger.new[0];
unAssignedCon.AccountId = a.Id;
}
}
}
This is i written , can you please update it for , if the account is that is deleted then contact is not assigne any account.
All Answers
Every record has flag (field) IsDeleted that you can use in your code (logic).
Nash
Account a = [Select Id from Account where Id='001M0000007VNAe' limit 1];
for(Contact c :trigger.new){
if(a != null){
if(trigger.new[0].accountid == null){
system.debug('>>> Selected Id - '+a.Id);
Contact unAssignedCon = trigger.new[0];
unAssignedCon.AccountId = a.Id;
}
}
}
This is i written , can you please update it for , if the account is that is deleted then contact is not assigne any account.