官术网_书友最值得收藏!

Solution 1 - using an Apex trigger

Because this requirement means that many child records (opportunities) need to be updated when a parent record (Account) is edited, we can't achieve the preceding business requirement using the Workflow rule. The next possibility is to use an Apex trigger. Generally, a developer writes an Apex trigger on the Account object to update all the open opportunities when an account's custom field, out of business, gets updated to True. The following is the sample code:

trigger UpdateRelatedOpportunites on Account (after update) { 
for (Account AccountToUpdate : trigger.new)
{
If (AccountToUpdate.Out_Of_Business__c==True)
{
// Your logic;
}
}
}

In addition, you'll need a test class and then use a change set, Force.com IDE or Force.com Migration Tool, to deploy the trigger and test classes to production. This also means that any change to the business logic will require more development work.

主站蜘蛛池模板: 南郑县| 应用必备| 修水县| 东海县| 孝感市| 仁寿县| 屏东市| 大余县| 大冶市| 普定县| 区。| 临夏市| 洪泽县| 铁力市| 芦山县| 长治县| 洛隆县| 施秉县| 云安县| 邛崃市| 宜春市| 龙南县| 故城县| 丰台区| 水富县| 巴东县| 成武县| 视频| 邵阳市| 龙海市| 友谊县| 民权县| 琼中| 芦山县| 阜新市| 龙胜| 二连浩特市| 陵川县| 定陶县| 泾阳县| 昌吉市|