CreateClaim(CreateClaimInput)

Create a claim record.

API Version 

65.0

Requires Chatter 

No

Signature 

public static ConnectApi.CreateClaimOutputRepresentation CreateClaim(ConnectApi.ClaimInputRepresentation CreateClaimInput)

Parameters 

CreateClaimInput

Return Value 

Type: ConnectApi.CreateClaimOutputRepresentation

Example 

Use this Apex example to create a new insurance claim by using the Create Claim API. This example shows how to create a ClaimInputRepresentation with claim details, participants, and items, and then invoke the Connect API method ConnectApi.ClaimFamily.CreateClaim() to submit the claim.

Class Definition

This Apex sample shows how to use the Create Claim API from the Connect API namespace to create an insurance claim record. The example includes building nested input structures for claim details, participants, claim items, and related objects.

1public with sharing class CreateClaimCallable 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 == 'createClaim') {
10            // Retrieve the claim input data from the input map
11            ConnectApi.ClaimInputRepresentation claimInput = (ConnectApi.ClaimInputRepresentation) inputMap.get('claimInput');
12            System.debug('Start of connect API call to create claim');
13
14            // Initialize the claim output representation
15            ConnectApi.CreateClaimOutputRepresentation claimData;
16
17            // Call the Connect API to create the claim
18            try {
19                claimData = ConnectApi.ClaimFamily.createClaim(claimInput);
20                System.debug('Claim created successfully: ' + claimData);
21
22                // Put the claim data in the output map
23                outputMap.put('claimData', claimData);
24            }
25            catch (Exception e) {
26                System.debug('Error while creating claim: ' + e.getMessage());
27                outputMap.put('error', e.getMessage());
28            }
29
30            // Return the claim data
31            return claimData;
32        }
33
34        // If the action is not recognized, return null
35        return null;
36    }
37}

Usage Example

Use the CreateClaimCallable class to invoke the createClaim action and submit a new claim.

1CreateClaimCallable callable = new CreateClaimCallable();
2
3// Prepare the input arguments
4Map<String, Object> input = new Map<String, Object>();
5
6// Create and populate the ClaimInputRepresentation object
7ConnectApi.ClaimInputRepresentation claimInput = new ConnectApi.ClaimInputRepresentation();
8
9// Set basic claim fields
10claimInput.name = 'Claim-Demo-Test-apex-1';
11claimInput.claimType = 'Auto';
12claimInput.lossDate = DateTime.now();
13claimInput.productCode = 'AutoClaimRoot';
14claimInput.claimReasonType = 'Accident';
15claimInput.claimReason= 'Damage';
16claimInput.lossType = 'Partial Loss';
17claimInput.insurancePolicyId = '0YTxx000000000iGAA';
18claimInput.accountId = '001xx000003GYiEAAW';
19claimInput.expenseReserveAmount = 750.50;
20claimInput.expenseReserveAdjustmentReason = 'Initial expense reserve';
21claimInput.lossReserveAmount = 5000.00;
22claimInput.lossReserveAdjustmentReason = 'Initial loss reserve';
23
24// Set additional fields
25Map<String, Object> additionalFields = new Map<String, Object>();
26additionalFields.put('Severity', 'High');
27claimInput.additionalFields = additionalFields;
28
29// Set claim items
30List<ConnectApi.ClaimItemInputRepresentation> itemList = new List<ConnectApi.ClaimItemInputRepresentation>();
31
32// Create first item
33ConnectApi.ClaimItemInputRepresentation item1 = new ConnectApi.ClaimItemInputRepresentation();
34item1.name = 'item1';
35item1.category = 'Involved Injury';
36item1.productCode = 'InvolvedInjury';
37item1.instanceKey = 'item1';
38item1.insuredItemId = '0YWxx00000000NbGAI';
39item1.insurancePolicyCoverageId = '0cYxx0000000125EAA';
40item1.participantInstanceKey = 'par1';
41
42// Set item attributes
43List<ConnectApi.ClaimAttributeInputRepresentation> item1AttrList = new List<ConnectApi.ClaimAttributeInputRepresentation>();
44
45ConnectApi.ClaimAttributeInputRepresentation genderAttr = new ConnectApi.ClaimAttributeInputRepresentation();
46genderAttr.apiName = 'Gender';
47genderAttr.value = 'Female';
48item1AttrList.add(genderAttr);
49
50item1.attributes = item1AttrList;
51
52// Set item additional fields
53Map<String, Object> item1AdditionalFields = new Map<String, Object>();
54    item1AdditionalFields.put('Description', 'test');
55item1.additionalFields = item1AdditionalFields;
56
57// Set item related objects
58List<ConnectApi.ClaimRelatedObjectInputRepresentation> relatedObjList = new List<ConnectApi.ClaimRelatedObjectInputRepresentation>();
59
60ConnectApi.ClaimRelatedObjectInputRepresentation accountRel = new ConnectApi.ClaimRelatedObjectInputRepresentation();
61accountRel.recordId = '001xx000003GYiBAAW';
62accountRel.recordObjName = 'Account';
63relatedObjList.add(accountRel);
64
65item1.relatedObjects = relatedObjList;
66
67itemList.add(item1);
68claimInput.items = itemList;
69
70// Set claim participants
71List<ConnectApi.ClaimParticipantInputRepresentation> participantList = new List<ConnectApi.ClaimParticipantInputRepresentation>();
72
73// Create first participant
74ConnectApi.ClaimParticipantInputRepresentation participant1 = new ConnectApi.ClaimParticipantInputRepresentation();
75participant1.instanceKey = 'par1';
76participant1.accountId = '001xx000003GYiEAAW';
77participant1.contactId = '003xx000004WhFwAAK';
78participant1.insurancePolicyParticipantId = '0aoxx00000000SQAAY';
79participant1.isInjured = 'true';
80participant1.roles = new List<String>{'Claimant', 'Involved Driver'};
81
82participantList.add(participant1);
83
84// Create second participant
85ConnectApi.ClaimParticipantInputRepresentation participant2 = new ConnectApi.ClaimParticipantInputRepresentation();
86participant2.instanceKey = 'par2';
87participant2.contactId = '003xx000004WhFwAAK';
88participant2.isInjured = 'true';
89participant2.roles = new List<String>{'Claimant', 'Involved Driver'};
90
91participantList.add(participant2);
92claimInput.participants = participantList;
93
94
95// Add the claimInput to the input map
96input.put('claimInput', claimInput);
97
98// Prepare the output map
99Map<String, Object> output = new Map<String, Object>();
100
101// Prepare the args map
102Map<String, Object> args = new Map<String, Object>();
103args.put('input', input);
104args.put('output', output);
105
106// Call the 'createClaim' action
107Object result = callable.call('createClaim', args);
108
109// Retrieve the claim data from the result
110ConnectApi.CreateClaimOutputRepresentation claimData = (ConnectApi.CreateClaimOutputRepresentation) result;
111
112// Output the claim data to the debug log
113System.debug('Claim Data: ' + JSON.serializePretty(claimData));
114
115// Check for errors in the output map
116if (output.containsKey('error')) {
117    System.debug('Error: ' + output.get('error'));
118}