function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Please try the below code.
// Apex Class
public class InsertedContact {
public static void createNewContact(List<Contact> contList)
{
List<Account> accountList = new List<Account>();
accountList = [SELECT Id,Name FROM ACCOUNT WHERE NAME='BuilingStreet'];
if(accountList.size()>0)
{
for(Contact con: contList)
{
if(con.Phone == '999')
{
con.AccountId = accountList[0].Id;
con.LastName = 'With BuilingStreet';
}
}
}
}
}
// Trigger
trigger createContact on Contact (before insert) {
if(Trigger.IsInsert && Trigger.IsBefore)
{
InsertedContact.createNewContact(Trigger.old);
}
}
Please select it as Best answer if you find it helpful.
Thank You,
Ajay Dubedi
If we write trigger.new then the code is working.
Yes, it will work for Trigger.New because trigger is firing on before insert.It was my mistake.
Please mark it as best answer if it resolves your problem.
Thank You,
Ajay Dubedi