将 Apex 触发器更新为屏幕重新认证应用程序
更新创建福利类别的个人申请记录时运行的 Apex 触发器。配置触发器,以在重新认证申请通过筛选并处于审核状态时发布 BMRecertEvent。BMRecertEvent 的事件处理器会更新与申请相关的福利分配的重新认证状态。
所需的 Edition
| 查看支持的产品版本。 |
| 所需用户权限 | |
|---|---|
| 更新 Apex 触发器: | 作者 Apex |
- 从“设置”中,在对象管理器中,选择“个人应用程序”。
- 单击 ⁇ 触发器。
-
对于 ProcessIAForBenefitAssistance,单击
,然后选择编辑。
-
将此代码粘贴到文本框。用贵组织中安装的 Omnistudio 软件包的命名空间前缀替换 ⁇ Omnistudio-Namespace-Prefix ⁇ 。
从“设置”中,在“已安装软件包”页面上查找 Omnistudio 软件包的命名空间前缀。
trigger ProcessIAForBenefitAssistance on IndividualApplication (after update) { String procedureNameForNewIA = 'BenefitManagement_ProcessIndividualApplication'; Map <String, Object> ipInput = new Map <String, Object> (); Map <String, Object> ipOutput = new Map <String, Object> (); Map <String, Object> ipOptions = new Map <String, Object> (); // List to hold the Platform Events to be published List<BMRecertEvent__e> eventsToPublish = new List<BMRecertEvent__e>(); // Iterate through the inserted or updated records for (IndividualApplication ia : Trigger.new) { if(ia.Status == 'Submitted' && ia.Category == 'Benefit') { String recordId = ia.Id; ipInput.put('RecordId', recordId); /* Call the IP via runIntegrationService, and save the output to ipOutput */ ipOutput = (Map <String, Object>) Omnistudio-Namespace-Prefix.IntegrationProcedureService.runIntegrationService(procedureNameForNewIA, ipInput, ipOptions); System.debug('IP Output: ' + ipOutput); IndividualApplication iaRecord = [SELECT Id, Status, ApplicationType, Category FROM IndividualApplication WHERE Id = :ia.Id]; if(iaRecord.Status != 'Denied' && iaRecord.ApplicationType == 'Recertification'){ BMRecertEvent__e event = new BMRecertEvent__e(); // Set fields on the Platform Event based on the inserted or updated record event.RecordId__c = iaRecord.Id; // Add the Platform Event to the list of events to be published eventsToPublish.add(event); } } } // Publish the list of Platform Events if (!eventsToPublish.isEmpty()) { EventBus.publish(eventsToPublish); } } - 保存更改。
本文章是否解决您的问题?
请与我们共享您的想法,以便我们进行改进!

