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

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.

主站蜘蛛池模板: 瑞金市| 黑河市| 广丰县| 西藏| 且末县| 子洲县| 西林县| 革吉县| 沾益县| 永和县| 吉林省| 阳城县| 连山| 景洪市| 合川市| 新郑市| 扬中市| 承德县| 巴楚县| 河源市| 外汇| 辽宁省| 刚察县| 九江县| 阿拉尔市| 长沙县| 龙里县| 平湖市| 永修县| 天台县| 南汇区| 永兴县| 嘉峪关市| 广平县| 余干县| 济宁市| 松原市| 方城县| 平罗县| 岳普湖县| 阿坝|