Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
UpdateClaim(claimId, UpdateClaimInput)
Update the details of a specific claim.
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.CreateClaimOutputRepresentation UpdateClaim(String claimId, ConnectApi.ClaimInputRepresentation UpdateClaimInput)
Parameters
- claimId
- Type: String
- ID of the claim to update.
- UpdateClaimInput
- Type: ConnectApi.ClaimInputRepresentation
- Details to update the claim.
Return Value
Example
The UpdateClaimCallable Apex class provides a way to update insurance claims by using the Connect API.
- Class Definition
-
1 2public with sharing class UpdateClaimCallable implements System.Callable { 3 4 public Object call(String action, Map<String, Object> args) { 5 Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); 6 Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); 7 8 if (action == 'updateClaim') { 9 ConnectApi.ClaimInputRepresentation claimInput = 10 (ConnectApi.ClaimInputRepresentation) inputMap.get('claimInput'); 11 System.debug('Starting Connect API call to update claim'); 12 13 ConnectApi.CreateClaimOutputRepresentation claimData; 14 try { 15 claimData = ConnectApi.ClaimFamily.updateClaim('0Zkxx00000000BJCAY', claimInput); 16 System.debug('Claim updated successfully: ' + claimData); 17 outputMap.put('claimData', claimData); 18 } catch (Exception e) { 19 System.debug('Error updating claim: ' + e.getMessage()); 20 outputMap.put('error', e.getMessage()); 21 } 22 23 return claimData; 24 } 25 26 return null; 27 } 28} - Usage Example
-
1UpdateClaimCallable callable = new UpdateClaimCallable(); 2 3// Prepare input map 4Map<String, Object> input = new Map<String, Object>(); 5 6// Create ClaimInputRepresentation object 7ConnectApi.ClaimInputRepresentation claimInput = new ConnectApi.ClaimInputRepresentation(); 8claimInput.name = 'Claim-Demo-Test-apex-update'; 9claimInput.claimType = 'Auto'; 10claimInput.lossDate = DateTime.now(); 11claimInput.productCode = 'AutoClaimRoot'; 12claimInput.claimReasonType = 'Accident'; 13claimInput.claimReason = 'Damage'; 14claimInput.lossType = 'Repairs'; 15claimInput.insurancePolicyId = '0YTxx000000000iGAA'; 16claimInput.accountId = '001xx000003GYnoAAG'; 17 18// Additional claim fields 19claimInput.additionalFields = new Map<String, Object>{ 'Severity' => 'Medium' }; 20 21// Set claim participants 22ConnectApi.ClaimParticipantInputRepresentation participant1 = new ConnectApi.ClaimParticipantInputRepresentation(); 23participant1.action = 'update'; 24participant1.instanceKey = 'par1'; 25participant1.accountId = '001xx000003GYnoAAG'; 26participant1.contactId = '003xx000004WhFwAAK'; 27participant1.insurancePolicyParticipantId = '0aoxx00000000SQAAY'; 28participant1.isInjured = 'false'; 29participant1.roles = new List<String>{'Claimant'}; 30 31ConnectApi.ClaimParticipantInputRepresentation participant2 = new ConnectApi.ClaimParticipantInputRepresentation(); 32participant2.action = 'create'; 33participant2.instanceKey = 'par3'; 34participant2.contactId = '003xx000004WhFwAAK'; 35participant2.isInjured = 'true'; 36participant2.roles = new List<String>{'Claimant', 'Involved Driver'}; 37 38claimInput.participants = new List<ConnectApi.ClaimParticipantInputRepresentation>{participant1, participant2}; 39 40// Set claim items (update or create) 41ConnectApi.ClaimItemInputRepresentation item1 = new ConnectApi.ClaimItemInputRepresentation(); 42item1.action = 'update'; 43item1.name = 'item1-updated'; 44item1.category = 'Involved Injury'; 45item1.productCode = 'InvolvedInjury'; 46item1.instanceKey = 'item1'; 47item1.insuredItemId = '0YWxx00000000NbGAI'; 48item1.insurancePolicyCoverageId = '0cYxx0000000125EAA'; 49item1.participantInstanceKey = 'par1'; 50item1.attributes = new List<ConnectApi.ClaimAttributeInputRepresentation>{ 51 new ConnectApi.ClaimAttributeInputRepresentation('Gender', 'Male') 52}; 53item1.additionalFields = new Map<String, Object>{ 'Description' => null }; 54item1.relatedObjects = new List<ConnectApi.ClaimRelatedObjectInputRepresentation>{ 55 new ConnectApi.ClaimRelatedObjectInputRepresentation('001xx000003GYnoAAG', 'Account') 56}; 57 58ConnectApi.ClaimItemInputRepresentation item2 = new ConnectApi.ClaimItemInputRepresentation(); 59item2.action = 'create'; 60item2.name = 'item2-created'; 61item2.category = 'Involved Injury'; 62item2.productCode = 'InvolvedInjury'; 63item2.instanceKey = 'item2'; 64item2.insuredItemId = '0YWxx00000000NbGAI'; 65item2.insurancePolicyCoverageId = '0cYxx0000000125EAA'; 66item2.participantInstanceKey = 'par2'; 67item2.attributes = new List<ConnectApi.ClaimAttributeInputRepresentation>{ 68 new ConnectApi.ClaimAttributeInputRepresentation('Gender', 'Male') 69}; 70item2.additionalFields = new Map<String, Object>{ 'Description' => 'test added' }; 71item2.relatedObjects = new List<ConnectApi.ClaimRelatedObjectInputRepresentation>{ 72 new ConnectApi.ClaimRelatedObjectInputRepresentation('001xx000003GYnoAAG', 'Account') 73}; 74 75claimInput.items = new List<ConnectApi.ClaimItemInputRepresentation>{item1, item2}; 76 77// Add claimInput to input map 78input.put('claimInput', claimInput); 79 80// Prepare output map 81Map<String, Object> output = new Map<String, Object>(); 82 83// Execute updateClaim action 84Map<String, Object> args = new Map<String, Object>{ 'input' => input, 'output' => output }; 85ConnectApi.CreateClaimOutputRepresentation claimData = 86 (ConnectApi.CreateClaimOutputRepresentation) callable.call('updateClaim', args); 87 88// Log results 89System.debug('Claim Data: ' + JSON.serializePretty(claimData)); 90if (output.containsKey('error')) { 91 System.debug('Error: ' + output.get('error')); 92}