Data Portability Process – Hub-Spoke Orchestration

To perform Data Portability on the request of any user, Create a Hub Request in Hub Org using Portability Hub Request API as shown below. Pass the necessary information in the POST method body so Privacy-Security Hub will process the request and will create appropriate Hub Request records.

Note: Users can create Hub Request records manually through the Salesforce UI. 

Navigate to a REST tool such as Workbench, Postman, Insomnia, etc. (This example uses Salesforce Developer Workbench) https://workbench.developerforce.com/restExplorer.php 

Select the radio button POST and put the below URL in the URL box.

POST URL –

/services/apexrest/cchub/v1/hub/createPortability


Request Body – Add all the necessary details in the request body related to the record that the user wants to Port the data.

{
“nameValuePair”: {
“Email”: “aniket@cloudcompliance.app”,
“LastName”: “Save”,
“Firstname”: “Aniket”,
“Phone”: “7400401544”
},
“externalDSARNumber”: “EXT999”,
“requestedOn”: “2021-10-31T23:59:59.000Z”,
“verifiedOn”: “2021-10-31T23:59:59.000Z”
}


Click on the execute button and the user will get a response with the Hub Request Number. 


User can give NameValuePair formats and data type as follows

Date :- “Birthdate”:”1994-06-14″

Date and Time :- “Login_Date_and_Time__c”:”2021-12-15T00:00:00.000Z”

Time :- “Submission_Time__c”:”00:00:00.000Z”

Percentage :- “Percentile__c”:10

Number :- “Passport_Number__c”:123456789

Text:- “LastName”:”Wood”

Now go to the salesforce and open the Hub Request record. Users will find all the necessary details on the details page like

Status = Open,  Type = Portability, Data Subject Identifier = {“Phone”:”7400401544″,”FirstName”:”Aniket”,”LastName”:”Save”,”Email”:”aniket@cloudcompliance.app“}


Initially, all other sections and fields will show no record or details.


Now run command 2 through the developer console.

Command 2:

cchub.HubSchedulableService.scheduleRequestIntitateBatch(null, null);

Note – User can schedule this command using cron expressions

To execute the command, click on the gear symbol in Salesforce org and click on Developer Console.


Open the anonymous window in the developer console, put the command in the window and click on the execute button.


Once the user clicks on the Execute button, all the processes within this command will get executed one by one as follows – 

  • It will create Spoke request records. Users will find all the newly created Spoke Request records in the related list of the respective Hub-Request records.
  • Based on the SOQL/where clause in the Hub-Spoke Object record it will fetch the Data Subject Ids from each of the spoke org. Those Data Subject Id records will be stored in the respective Spoke Request records. 
  • With all the necessary inputs gathered in the Spoke Request record, Privacy-Security will trigger the Spoke API (RTBF/Portability).  

Now go to the Hub Request record and check the Spoke Request section. Users will find all the Spoke requests from all the Spoke orgs that are connected to the Hub Org. Also, users will find the status “In Progress”.

Now Run Command 3 which further includes two more batches.

Command 3:

cchub.HubSchedulableService.scheduleStatusRequestBatch(null,null);

  • Initially, this command is used to fire the GET spoke API which contains all the details about the case and the initial status of the operation. 
  • After the above operation, the next process gets started and after execution, the user can see the final status for the record in Hub org. For all the successful spoke requests, the status will be “Processed” for both the Operations (RTBF/Portability) and in the Sub-Status field, for successful RTBF operation Sub-Status will be “Processed” and for successful Portability operation Sub-Status will be “Attachment Generated”.

    Note: In the case of Portability, the user can find the generated JSON file in the related list of Hub-Spoke requests as well as respective Spoke Request records.

Open the anonymous window in the developer console, put the command in the window and click on the execute button.


After execution of the command, the user can see the change in status and sub-status of the respective Spoke Request record. 


Now the status of the Hub request will be changed from In-Progress to Processed


Also, users can find JSON files in the related list of Hub Request records.


In this way, users can process Data Portability requests from Hub org to multiple Spoke Orgs.

In case of Error and Retry – 

In case any Hub Request record fails while processing RTBF/Data Portability, In that case, “Retry Now” button will appear on that particular Hub Request record detail page.  Once user solve the problem at spoke org, then the user can click on the “Retry Now” button and it will edit the Status of Errored records of Hub Request & Spoke Request so that these records based on their Statuses will be picked by Command 2 and then command 3 on the next schedule.


If working on multiple or Bulk HubRequest Errored records, the via Data Loader edit the field ‘cchub__Retry__c’ = True and then Execute the command 
 

Command 4: 

“cchub.HubSchedulableService.scheduleRetryBatch(null,null);”        

The command is used to edit the status of all Errored records of Hub Request & Spoke Request and changes it to “Open”. Once the user solves the problem at the Spoke org, these records based on their Statuses will be picked by Command 2 and then Command 3 on the next schedule.
 

Status Transition – Hub Request & Spoke Request 

HUBMeaning
Level StatusSub StatusError message
HUB RequestOpenNULL No Spoke Request records. Processing has not started yet
In ProgressNULL Once all Spoke Request records are created. In Processing
ErrorNULLIncorrect JSON(Hub Request JSON wrong/ One or more Spoke Request records in error)
ProcessedNULL All Spoke Request records processed with no error
 SPOKE RequestOpenNULL If Spoke PrivSec Id Is Null
In ProgressNULL If Spoke PrivSec Id Is Not Null
New If PrivSec  Status=New
Validated If PrivSec =Validated
Records Generated if PrivSec Status=Record Generated
ErrorToo Many Records Found When one or more records are found of the same name-value pair
Incorrect MappingMapping does not exist or is inactiveIncorrect mapping name,  Mapping is inactive
Missing ParametersMandatory parameter XXXX is missing 
Exception JWT user does not have access to the Field of a particular object
Record Not FoundIf based on the name-value pair, no record is foundNot found any record of the given name-value pair
ProcessedInsufficient Information Not enough information to call an org(handled by Batch1 in Hub itself)
Processed In RTBF, If Spoke Org returns PrivSec Status as Processed
Attachments Generated In Portability, If Spoke Org returns PrivSec Status as Processed
Record Not Found Not found any record of the given name-value pair