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

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.

主站蜘蛛池模板: 海门市| 灌云县| 郓城县| 高要市| 金山区| 于都县| 龙口市| 青浦区| 临高县| 云霄县| 城市| 察隅县| 叙永县| 宽城| 张家川| 司法| 北票市| 邹平县| 嘉荫县| 营口市| 嘉义县| 商河县| 方山县| 正安县| 富源县| 固安县| 东宁县| 县级市| 阿合奇县| 监利县| 江川县| 仁怀市| 南涧| 湘潭县| 宜君县| 伽师县| 江城| 洛阳市| 鹤山市| 崇州市| 乌苏市|