cancelInsurancePolicy(insurancePolicyCancelInput, policyId)
Cancel a specific insurance policy by providing the cancellation details and the policy
ID.
API Version
67.0
Requires Chatter
No
Signature
public static ConnectApi.InsurancePolicyCancellationRepresentation cancelInsurancePolicy(ConnectApi.InsurancePolicyCancellationInputRepresentation insurancePolicyCancelInput, String policyId)
1ConnectApi.InsuranceBrokerageFamily, cancelInsurancePolicy, [ConnectApi.InsurancePolicyCancellationInputRepresentation, String], ConnectApi.InsurancePolicyCancellationRepresentationParameters
- insurancePolicyCancelInput
- Type: ConnectApi.InsurancePolicyCancellationInputRepresentation
- Input representation containing the cancellation effective date, reason, and target status for the canceled policy.
- policyId
- Type: String
- ID of the insurance policy to cancel.
Return Value
Usage
Use this method to cancel a specific insurance policy. Provide the cancellation effective date, reason, and target status in the input representation, along with the ID of the policy to cancel. The policy is canceled synchronously, and the response includes the transaction ID, impacted policy versions, and any errors.
Example
The Apex example shows how to use the ConnectApi.InsuranceBrokerageFamily.cancelInsurancePolicy() method to cancel a specific insurance policy.
- Class Definition
- This Apex example shows how to cancel an insurance policy.
-
1global class CancelConnectDriver { 2 3 global static void callCancelConnectAPI() { 4 Map<String, Object> input = new Map<String, Object>(); 5 input.put('policyId', '0YTxx000000001dGAA'); 6 7 ConnectApi.InsurancePolicyCancellationInputRepresentation cancelInput = new ConnectApi.InsurancePolicyCancellationInputRepresentation(); 8 cancelInput.cancellationEffectiveDate = '2026-07-01'; 9 cancelInput.status = 'Cancelled'; 10 cancelInput.cancellationReason = 'Customer Request'; 11 12 input.put('policyInput', cancelInput); 13 14 Map<String, Object> output = new Map<String, Object>(); 15 Map<String, Object> args = new Map<String, Object>(); 16 args.put('input', input); 17 args.put('output', output); 18 19 CancelTestConnectAPI callable = new CancelTestConnectAPI(); 20 Object result = callable.call('cancel', args); 21 22 ConnectApi.InsurancePolicyCancellationRepresentation policyData = 23 (ConnectApi.InsurancePolicyCancellationRepresentation) result; 24 System.debug('Cancel Policy Data: ' + JSON.serializePretty(policyData)); 25 26 if (output.containsKey('error')) { 27 System.debug('Error: ' + output.get('error')); 28 } 29 } 30} - Usage Example
- Use the CancelTestConnectAPI class to execute the cancel action and process the result.
-
1public class CancelTestConnectAPI implements System.Callable { 2 3 public Object call(String action, Map<String, Object> args) { 4 Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); 5 Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); 6 7 if (action == 'cancel') { 8 ConnectApi.InsurancePolicyCancellationInputRepresentation cancelInput = 9 (ConnectApi.InsurancePolicyCancellationInputRepresentation) inputMap.get('policyInput'); 10 String policyId = (String) inputMap.get('policyId'); 11 System.debug('Start of Connect API call to cancel policy: ' + policyId); 12 13 ConnectApi.InsurancePolicyCancellationRepresentation policyData; 14 try { 15 policyData = ConnectApi.InsuranceBrokerageFamily.cancelInsurancePolicy(cancelInput, policyId); 16 System.debug('Policy cancelled successfully: ' + policyData); 17 outputMap.put('policyData', policyData); 18 } catch (Exception e) { 19 System.debug('Error while cancelling policy: ' + e.getMessage()); 20 outputMap.put('error', e.getMessage()); 21 } 22 return policyData; 23 } 24 25 return null; 26 } 27} 28 29// Execute 30CancelConnectDriver.callCancelConnectAPI();