To write bulk safe triggers we need to understand and utilize sets and maps. Sets are used to isolate distinct records, while maps are name-value pairs that hold the query results retrievable by record id. for more details refer the Apex developer guide.
Example:
======
trigger ChangeColor on Account (before insert, before update)
{
// create a set of all the unique ownerIds
Set<id> ownerIds = new Set<id>( );
for (Account a : Trigger.new)
{
ownerIds.add(a.OwnerId);
}
// query for all the User records for the unique userIds
Map<id, User> owners = new Map<id, User>([Select Favorite_Color__c from User Where Id in
:ownerIds]);
// iterate over the list of records being processed
for (Account a : Trigger.new)
{
a.Owner_Favorite_Color__c = owners.get(a.OwnerId).Favorite_Color__c;
}
}
This comment has been removed by the author.
ReplyDeleteSalesforce is a cloud based CRM software. Today's most of the IT industry use this software for customer relationship management. To get more details about salesforce please refer this site.
ReplyDeleteRegards..
Salesforce Training
Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers. Amazon Web Services Training in Chennai | AWS Training
ReplyDeleteNice blog on Hadoop Technology!!! I agree with your points, Big Data Hadoop technology is ruling the whole organization to handle data in efficient manner. HDFS and Map reduce helps the developer in different ways to manage data.
ReplyDeleteRegards:
Hadoop Training in Chennai |
Big Data Training in Chennai
Testing an application is become essential for any product to get an effective
ReplyDeleteresult. Your post help you to gain more info on Selenium Testing
Selenium Training in chennai |
Selenium Courses in Chennai