This document outlines the functionality of the BatchGetP2ContainerStatus batch process in Secure File Transport, which is responsible for capturing the Current Status of the P2 Container.
🛠️ Batch Job: BatchGetP2ContainerStatus
-
Captures latest status of the P2 Container once the initial request is made.
🔍 How It Works
-
Fetch Records
QueriesGetP2StatusQueryrecords that meet all the following conditions:-
Default where clause:
-
cm_datatransfer__Request_Id__c!= null -
CreatedDate= ‘Last 50 days’
-
-
Configurable where clause:
-
Data Transfer Settings → P2StatusBatch_WhereClause (should starts with where)
-
-
-
Capture Attempt
-
Make an API call to get the recent status
-
-
Success Handling
If the capture is successful:-
✅
API Status→ Updated to Sent
-
-
Failure Handling
If the capture fails:-
❌
API Status→ Updated to Request Failed -
❌
API Status Description(or error message field) → Populated with the Error Description
-
-
Common Settings
-
P2StatusNextRunTime- Sets the time in seconds when the next instance of the Batch will run. If the entry does not exists then the Batch will not trigger again. -
BatchSize_P2Status- Configure the Batch Size. Max: 100 since in one transaction only 100 API calls can be made.
-
🧠 Automation
-
This batch can be scheduled to run daily to automatically process all the Pending Container Status
💻 Execution Script
👉 Run batch without filter (uses default query):
Database.executeBatch(new BatchGetP2ContainerStatus(), 1);
👉 Run batch with a custom SOQL query:
String sQuery = 'SELECT Id, cm_finance__Payment_Status__c, cm_finance__Payment_Mode__c, cm_finance__Transaction_Id__c, cm_finance__Payment_Gateway__c, cm_finance__Transaction_Status__c, cm_finance__Amount__c, cm_finance__Application_Fee__c, cm_finance__Payment_Method__r.cm_finance__Holder_Full_Name__c, cm_finance__Payment_Method__r.RecordType.Name, cm_finance__Payment_Method__r.cm_finance__Encrypted_Token__c,cm_finance__Payment_Method__r.cm_finance__Card_Expiration_Year__c, cm_finance__Payment_Method__r.cm_finance__Card_Expiration_Month__c, cm_finance__Payment_Gateway__r.cm_finance__Payment_Gateway__c, cm_finance__Payment_Gateway__r.Name, cm_finance__Payment_Method__r.cm_finance__Bank_Account_Owner_Type__c, cm_finance__Payment_Method__r.cm_finance__Bank_Account_Type__c , cm_finance__Payment_Method__r.cm_finance__Location_User_Id__c FROM cm_finance__Payment_Transaction__c WHERE cm_finance__Payment_Status__c = \'Authorized\' and cm_finance__Payment_Date__c<=today';
Database.executeBatch(new BatchGetP2ContainerStatus(sQuery), 1);
👉 Run batch with customized where clause (uses custom where clause):
Setup the Custom Where clause in the Data Transfer Settings
-
Navigate to Setup -> Custom Settings -> Data Transfer Settings
-
Create an Entry:
BatchP1Status_WhereClause. -
The value should start with ' and <clause 1> '
Database.executeBatch(new BatchPullFileRequestStatus(), 1);
Next run settings
-
ScheduleBatchRequired
-
Default is false.
-
Enables the next instance of the batch to run.
-
-
NextScheduleBatchRunTime
-
Time in minutes until the next instance of the batch runs.
-
✅ Benefits
📅 Ensures timely processing of all File Requests and reduce manual effort
📈 Tracks successful vs. failed capture attempts for auditing