Loading
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 Recertification Status When an Application Is in Review

          Update the Recertification Status When an Application Is in Review

          When a recertification application is in review, update the recertification status of the related benefit assignment to In Progress. Define a custom platform event that indicates that a recertification application is in review, and configure an event handler that updates the recertification status of the related benefit assignment when the platform event is published. Subscribe to the platform event by using an Apex trigger.

          Required Editions

          View supported product editions.
          User Permissions Needed
          To create and edit platform event definitions: Customize Application
          To define Apex triggers: Author Apex

          Define a Custom Platform Event

          1. From Setup, in the Quick Find box, enter Platform, and then select Platform Events.
          2. Click New Platform Event.
          3. Enter these details.
            • Label: BMRecertEvent
            • Plural Label: BMRecertEvents
            • Object Name: BMRecertEvent
          4. Save your changes.
          5. In the Custom Fields & Relationships list, click New.
          6. For Data Type, select Text, and then click Next.
          7. Enter these details.
            • Field Label: RecordId
            • Length: 50
            Field Name is autopopulated.
          8. Save your changes.

          Create an Apex Class for the Event Handler

          1. From Setup, in the Quick Find box, enter Apex, and then select Apex Classes.
          2. Click New.
          3. Paste this class definition into the text box.
            public class SubscribeBMRecertEvent {
                // Implement the event handler method
                @InvocableMethod(label='Handle BMRecertEvent Platform Event')
                public static void handleEvent(List<BMRecertEvent__e> events) {
                for (BMRecertEvent__e event : events) {        
                    List<IndividualApplication> recordsToUpdate = [SELECT Id, Status, ApplicationType, Category, BenefitAssignmentId FROM IndividualApplication WHERE Id = :event.RecordId__c];       
                    for (IndividualApplication ia: recordsToUpdate) {
                        BenefitAssignment baRecord = [SELECT Id, RecertificationStatus FROM BenefitAssignment WHERE Id = :ia.BenefitAssignmentId];
                        baRecord.RecertificationStatus = 'InProgress';
                        update baRecord;
                    }
                    }
                }
            }
          4. Save your changes.

          Subscribe to the Platform Event by Using an Apex Trigger

          1. From Setup, in the Quick Find box, enter Platform, and then select Platform Events.
          2. Click BMRecertEvent.
          3. In the Triggers list, click New.
          4. Paste this class definition into the text box.
            trigger BMRecertEventTrigger on BMRecertEvent__e (after insert) {
                SubscribeBMRecertEvent.handleEvent(Trigger.new);
            }
          5. Save your changes.
           
          Loading
          Salesforce Help | Article