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

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.

主站蜘蛛池模板: 广汉市| 肥城市| 平阳县| 张家口市| 丰镇市| 丽江市| 阿克陶县| 民县| 日喀则市| 广宗县| 白银市| 鄱阳县| 武川县| 双牌县| 吉林省| 宝坻区| 武陟县| 阿坝县| 公安县| 额敏县| 青海省| 大理市| 安国市| 和静县| 灵武市| 莱州市| 调兵山市| 黑龙江省| 南平市| 碌曲县| 肥西县| 墨脱县| 高淳县| 天柱县| 香港 | 山西省| 金阳县| 峨边| 卓资县| 怀来县| 托克托县|