APEX API PrivSec for Data Portability

Updated on March 20, 2023

The Data Portability feature of Cloud Compliance – GDPR Data Management generates files that include personal data. 

In the use cases where the Data Portability feature needs to be invoked by an external system, Cloud Compliance offers an APEX API interface.

This document explains how to invoke a mapping that is pre-configured via APEX API using a JSON-based callout. The API auto-creates a PrivSec Request and generates the PDF, CSV, Excel, and JSON files

The two different methods that are available for this APEX API are:-


Method 1. 

PCCC_DM.PCL_Wrapper.PCL_HubRequest hubRequest = new PCCC_DM.PCL_Wrapper.PCL_HubRequest();
hubRequest.nameValuePair = new Map < String, String > {
‘LastName’ => ‘Jones’,
‘FirstName’ => ‘Rick’
};
hubRequest.mappingName = ‘Contact Portability Mapping Spoke1’;
hubRequest.objectName = ‘Contact’;
hubRequest.externalRequest = ‘EXT117’;
hubRequest.requestedDate = system.today();
hubRequest.description = ‘This is description’;
hubRequest.alwaysCreateRequest = true;
hubRequest.storeNameValuePair = true;
hubRequest.plannedAssociatedRecordsPurgeDate = system.today();
hubRequest.batchSize = 200;
PCCC_DM.PCL_Wrapper.PCL_HubResponse res = PCCC_DM.CreatePrivSecPortabilityRequest.init(hubRequest);
system.debug(res);

Here,

nameValuePair – The user can pass multiple fields in the form of name-value pair that Cloud Compliance will use to identify the record and perform Data Portability. Inserting either First Name, Last Name as part of nameValuePair is mandatory. This field cannot be kept as blank.

objectName – Provide the object name on which the user wants to perform Data Portability. Object Name parameter is mandatory. The value of this field cannot be kept as blank.

mappingName – Provide an Appropriate mapping name for the appropriate object. Mapping Name parameter is mandatory. The value of this field cannot be kept as blank.

externalRequest – When a request is triggered from the external system it records the ID of the request

requestedDate – Actual Date on which the Portability request is initiated. The value of this field cannot be kept as blank.

Description – User can provide a relevant description for Data Portability operation.

alwaysCreateRequest – alwaysCreateRequest (Boolean) default is false. True implies that a PrivSec request is created even if no record is found based on the nameValue pair. This is needed to support Portability requests when SF pulls in data from other systems as well…and it is possible that the data subject is not found in SF.

storeNameValuePair – storeNameValuePair (Boolean) default is false. This may be needed by customers who may want to use this information through the Interface class to query other systems.

plannedAssociatedRecordsPurgeDate – The associated records with the PrivSec Request record will be deleted on the date which is mentioned in this field.

batchSize – Describes the number of records processed in batch. Recommended batch size is 200

Method 2. 

PCCC_DM.PCL_Wrapper.PCL_HubRequest hubRequest = new PCCC_DM.PCL_Wrapper.PCL_HubRequest();
hubRequest.requestId = ‘a0W4L000000KmFLUA0’;
hubRequest.sendJson = true;
PCCC_DM.PCL_Wrapper.PCL_HubResponse res = PCCC_DM.GetPrivSecPortabilityRequest.init(hubRequest);
system.debug(res);

Here,

requestId – A record id of PrivSec Request for which the user wants to get all details about Data Portability. 

sendJSON  – If true, Cloud Compliance will return all the field details of the processed record under Data Portability in the form of JSON. 


Solution Steps – 

1. Navigate to a Salesforce record (Contact record in this example) that the user wants to perform Data Portability on.

2. Copy all the necessary details that the user wants to pass in the body of the APEX API call in the form of name-value pair.

E.g. FirstName, LastName, Email, etc.

3. Open the Salesforce Developer Console, prepare the CreatePrivSecPortabilityRequest method and click on execute button.

Note– Make sure that Data Portability mapping is created for the object of the specified record.

PCCC_DM.PCL_Wrapper.PCL_HubRequest hubRequest = new PCCC_DM.PCL_Wrapper.PCL_HubRequest();
hubRequest.nameValuePair = new Map < String, String > {
‘LastName’ => ‘Jones’,
‘FirstName’ => ‘Rick’
};
hubRequest.mappingName = ‘Contact Portability Mapping Spoke1’;
hubRequest.objectName = ‘Contact’;
hubRequest.externalRequest = ‘EXT117’;
hubRequest.requestedDate = system.today();
hubRequest.description = ‘This is description’;
hubRequest.alwaysCreateRequest = true;
hubRequest.storeNameValuePair = true;
hubRequest.plannedAssociatedRecordsPurgeDate = system.today();
hubRequest.batchSize = 200;
PCCC_DM.PCL_Wrapper.PCL_HubResponse res = PCCC_DM.CreatePrivSecPortabilityRequest.init(hubRequest);
system.debug(res);

4. The APEX API returns a RequestId and a success message(hasError: false) and the PrivSec Request gets created in the Org.

5. Use the 2nd APEX API to get the Data Portability JSON using the RequestId.

Open the Salesforce Developer Console. Prepare the GetPrivSecPortabilityRequest method and click on execute button.

PCCC_DM.PCL_Wrapper.PCL_HubRequest hubRequest = new PCCC_DM.PCL_Wrapper.PCL_HubRequest();
hubRequest.requestId = ‘a0W4L000000KmFLUA0’;
hubRequest.sendJson = true;
PCCC_DM.PCL_Wrapper.PCL_HubResponse res = PCCC_DM.GetPrivSecPortabilityRequest.init(hubRequest);
system.debug(res);

6. The APEX API returns the Status, Sub-Status, and all other important details of PrivSec Request.