Users can use this APEX API to retrieve the latest consent by passing Individual Id. Cloud Compliance’s Grouping Rules of Individual will associate each and every contact or lead record with an Individual.
All the consent management is implemented around Individual Object. Hence just by passing the Individual Id or list of Individual Ids to the Consent Retrieval API user can fetch the latest consents associated with that Individual.
The method used for this APEX API is as follows –
1. Navigate to a Salesforce Contact/Lead record for which users want to fetch the latest consent record via APEX API. Here contact record is used as a sample. This contact record contains 2 consents (Contact Point Type Consent Records) – Sales -Email as Opt-In and Sales – SMS as Opt-Out.
2. This contact record is associated with the Individual.
3. Go to the Individual record and get the Id from the URL. The id is highlighted for reference in the screenshot –
4. Open the Salesforce Developer Console. Prepare the create getconsentdata method by passing the IndividualId as parameters and executing the code.
Note: Here ‘For’ loop is used to see details of the fetched consent records. This is optional.
The APEX API with For loop is as follows –
5. This API returns Consent records related to a Contact record. Here the two consent fetched is highlighted in screenshots. One is Opt-Out and another is Opt-In. These details can be further used as per the integration with other systems.