Apex bulk Trigger   Leave a comment

Bulk Trigger

Tigger on the child sobject.

to make a set<ParentID> from Trigger.New,
to make a Map<Id, Parent> by new Map([select XX from ParentSObject where id : set<ParentId>])
to loop the child sobject,
first: get parentid from child sobject.
second: using map to get parent sobject.
now you can get parent sobject(with fields you want) and child sobject(with the fields you want).

 

to make a parent id set by Trigger.oldMap.KeySet();
to get the list of child sobject by querying the child sobject [select XXX from childSObject where parentId in :set<ParentId>]
to loop the child sobject list
get parent sobject record by Trigger.oldMap.get(childSobjectRecord.parentId)
do something….

Posted 2012年04月24日 by gw8310 in salesforce

Tagged with , , ,

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: