CreateClaimCoverage(claimId, CreateClaimCoverageInput)
Create a claim coverage record.
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.ClaimCoverageRepresentation CreateClaimCoverage(String claimId, ConnectApi.CreateClaimCoverageInputRepresentation CreateClaimCoverageInput)
Parameters
- claimId
- Type: String
- ID of the claim to add coverage to.
- CreateClaimCoverageInput
- Type: ConnectApi.CreateClaimCoverageInputRepresentation
- Object that contains the details to create the claim coverage.
Return Value
Example
The Apex example shows how to use the ConnectApi.InsuranceClaimFamily.CreateClaimCoverage() method to create a claim coverage for an existing claim.
- Class Definition
-
1 2public with sharing class CreateClaimCoverageCallable implements System.Callable { 3 4 public Object call(String action, Map<String, Object> args) { 5 // Retrieve the input and output maps from the arguments 6 Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); 7 Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); 8 9 // Check the action type 10 if (action == 'createClaimCoverage') { 11 12 // Retrieve the coverage input data from the input map 13 ConnectApi.CreateClaimCoverageInputRepresentation coverageInput = 14 (ConnectApi.CreateClaimCoverageInputRepresentation) inputMap.get('coverageInput'); 15 16 System.debug('Start of Connect API call to create claim coverage'); 17 18 // Initialize the coverage output representation 19 ConnectApi.ClaimCoverageRepresentation coverageData; 20 21 try { 22 // Call the Connect API to create the claim coverage 23 // Replace the claim ID with the appropriate value for your org 24 coverageData = ConnectApi.ClaimFamily.createClaimCoverage( 25 '0Zkxx00000000JNCAY', // Claim ID 26 coverageInput 27 ); 28 29 System.debug('Claim coverage created successfully: ' + coverageData); 30 31 // Put the coverage data in the output map 32 outputMap.put('coverageData', coverageData); 33 } catch (Exception e) { 34 System.debug('Error while creating claim coverage: ' + e.getMessage()); 35 outputMap.put('error', e.getMessage()); 36 } 37 38 // Return the coverage data 39 return coverageData; 40 } 41 42 // If the action is not recognized, return null 43 return null; 44 } 45} - Usage Example
- This example shows how to call the CreateClaimCoverageCallable class and include the required input data.
-
1CreateClaimCoverageCallable callable = new CreateClaimCoverageCallable(); 2 3// Prepare the input arguments 4Map<String, Object> input = new Map<String, Object>(); 5 6// Create and populate the CreateClaimCoverageInputRepresentation object 7ConnectApi.CreateClaimCoverageInputRepresentation coverageInput = 8 new ConnectApi.CreateClaimCoverageInputRepresentation(); 9 10// Set required fields 11coverageInput.claimParticipantId = '0aSxx00000000CvEAI'; 12coverageInput.claimItemId = '0dqxx00000000McAAI'; 13coverageInput.insurancePolicyAssetId = '0YWxx00000000P5GAI'; 14coverageInput.insurancePolicyCoverageId = '0cYxx000000012GEAQ'; 15coverageInput.name = 'Apex Cov Test'; 16 17// Set optional fields 18coverageInput.lossReserveAmount = 25000.00; 19coverageInput.expenseReserveAmount = 2500.00; 20coverageInput.reserveProcessingMode = 'CoverageReserve'; 21coverageInput.currencyIsoCode = 'USD'; 22 23// Set additional fields 24Map<String, Object> additionalFields = new Map<String, Object>(); 25additionalFields.put('Description', 'Coverage for vehicle damage claim'); 26coverageInput.additionalFields = additionalFields; 27 28// Add the coverageInput to the input map 29input.put('coverageInput', coverageInput); 30 31// Prepare the output map 32Map<String, Object> output = new Map<String, Object>(); 33 34// Prepare the args map 35Map<String, Object> args = new Map<String, Object>(); 36args.put('input', input); 37args.put('output', output); 38 39// Call the 'createClaimCoverage' action 40Object result = callable.call('createClaimCoverage', args); 41 42// Retrieve the coverage data from the result 43ConnectApi.ClaimCoverageRepresentation coverageData = 44 (ConnectApi.ClaimCoverageRepresentation) result; 45 46// Log the created coverage data 47System.debug('Coverage Data: ' + JSON.serializePretty(coverageData)); 48 49// Check for errors in the output map 50if (output.containsKey('error')) { 51 System.debug('Error: ' + output.get('error')); 52}