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

Return Value 

Type: ConnectApi.ClaimCoverageRepresentation

Example 

The Apex example shows how to use the ConnectApi.InsuranceClaimFamily.CreateClaimCoverage() method to create a claim coverage for an existing claim.

Class Definition

1public with sharing class CreateClaimCoverageCallable implements System.Callable {
2
3    public Object call(String action, Map<String, Object> args) {
4        // Retrieve the input and output maps from the arguments
5        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
6        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
7
8        // Check the action type
9        if (action == 'createClaimCoverage') {
10
11            // Retrieve the coverage input data from the input map
12            ConnectApi.CreateClaimCoverageInputRepresentation coverageInput =
13                (ConnectApi.CreateClaimCoverageInputRepresentation) inputMap.get('coverageInput');
14
15            System.debug('Start of Connect API call to create claim coverage');
16
17            // Initialize the coverage output representation
18            ConnectApi.ClaimCoverageRepresentation coverageData;
19
20            try {
21                // Call the Connect API to create the claim coverage
22                // Replace the claim ID with the appropriate value for your org
23                coverageData = ConnectApi.ClaimFamily.createClaimCoverage(
24                    '0Zkxx00000000JNCAY', // Claim ID
25                    coverageInput
26                );
27
28                System.debug('Claim coverage created successfully: ' + coverageData);
29
30                // Put the coverage data in the output map
31                outputMap.put('coverageData', coverageData);
32            } catch (Exception e) {
33                System.debug('Error while creating claim coverage: ' + e.getMessage());
34                outputMap.put('error', e.getMessage());
35            }
36
37            // Return the coverage data
38            return coverageData;
39        }
40
41        // If the action is not recognized, return null
42        return null;
43    }
44}

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}