Secure File Transport

Setup Batch to get latest Status of Container

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

  1. Fetch Records
    Queries GetP2StatusQuery records that meet all the following conditions:

    1. Default where clause:

      1. cm_datatransfer__Request_Id__c != null

      2. CreatedDate = ‘Last 50 days’

    2. Configurable where clause:

      1. Data Transfer Settings → P2StatusBatch_WhereClause (should starts with where)

  2. Capture Attempt

    • Make an API call to get the recent status

  3. Success Handling
    If the capture is successful:

    • API Status → Updated to Sent

  4. Failure Handling
    If the capture fails:

    • API Status → Updated to Request Failed

    • API Status Description (or error message field) → Populated with the Error Description

  5. Common Settings

    1. 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.

    2. 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

  1. ScheduleBatchRequired

    • Default is false.

    • Enables the next instance of the batch to run.

  2. 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