Loading
Feature degradation | Gmail Email delivery failureRead More
Public Sector Documentation
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Update the Apex Trigger to Screen Recertification Applications

          Update the Apex Trigger to Screen Recertification Applications

          Update the Apex trigger that runs when an individual application record of the category Benefit is created. Configure the trigger to publish a BMRecertEvent when a recertification application passes the screening and is in review. The event handler for BMRecertEvent updates the recertification status of the benefit assignment related to the application.

          Required Editions

          View supported product editions.
          User Permissions Needed
          To update Apex triggers: Author Apex
          1. From Setup, in Object Manager, select Individual Application.
          2. Click Triggers.
          3. For ProcessIAForBenefitAssistance, click actions menu, and then select Edit.
          4. Paste this code in the text box. Replace Omnistudio-Namespace-Prefix with the namespace prefix of the Omnistudio package installed in your org.
            Find the namespace prefix of the Omnistudio package on the Installed Packages page in Setup.
            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);
                }
            }
          5. Save your changes.
           
          Loading
          Salesforce Help | Article