Escolar Documentos
Profissional Documentos
Cultura Documentos
c.firstname = 'Michael';
c.lastname = 'Oliver';
c.email = 'mo@gmail.com';
insert c;
colors.add('blue');
colors.add('red');
colors.add('blue');
colors.add('red');
system.debug('The details of contacts are:' + f.Firstname + '' + f.Lastname + 'Phone No:' + f.phone);
Trigger to validate the Amount field on opportunity object before inserting or updating a record
1trigger trigger_basic on Opportunity (Before Insert, Before Update)
2{
3for (Opportunity a : Trigger.new)
4{
5if (a.Amount < 501)
6{
7a.adderror('Amount value should be greater than 500');
8}
9}
1
0
1}
1
Trigger such that when a record is added in opportunities a new trigger is invoked such that a new
contact is also created
for(opportunity f : Trigger.new)
c.AccountID = f.AccountID;
c.Lastname = 'Jobs';
c.Firstname = 'Steve';
insert c;
}
}
try
c.firstname = 'xyz';
insert c;
catch(Exception e)
try
c.firstname = 'xyz';
insert c;
catch(DMLException e)
system.debug('Error:' + e);
}