GetClaim(claimId)
Get the details of a specific claim.
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.ClaimOutputRepresentation GetClaim(String claimId)
Parameters
- claimId
- Type: String
- ID of the claim to retrieve the details for.
Return Value
Example
Use this Apex example to retrieve claim details from the Claim Management system by using the Get Claim API. The example shows how to invoke the Connect API method ConnectApi.ClaimFamily.GetClaim() and handle responses and errors in Apex.
- Class Definition
- Here's an example that shows how to invoke the Get Claim API by using Apex.
-
1 2// Output the claim data to the debug log 3System.debug('Claim Data: ' + JSON.serializePretty(claimData));g 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 == 'getClaim') { 10 // Retrieve the claim ID from the input map 11 String claimId = (String) inputMap.get('claimId'); 12 System.debug('Start of connect API call to get claim with ID: ' + claimId); 13 14 // Initialize the claim output representation 15 ConnectApi.ClaimOutputRepresentation claimData; 16 17 // Call the Connect API to get the claim 18 try { 19 claimData = ConnectApi.ClaimFamily.getClaim(claimId); 20 System.debug('Claim retrieved 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 retrieving 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
- You can use the GetClaimCallable class in Apex to call the getClaim action and retrieve claim details by the claim ID.
-
1GetClaimCallable callable = new GetClaimCallable(); 2 3// Prepare the input arguments 4Map<String, Object> input = new Map<String, Object>(); 5 6// Get claimId from user input (you can modify this to get from different sources) 7// Option 1: From URL parameters (if called from a Visualforce page or Lightning component) 8String claimId = ApexPages.currentPage().getParameters().get('claimId'); 9 10if (String.isBlank(claimId)) { 11 System.debug('Please provide a claimId. You can set it in the input map.'); 12} 13 14// Add the claimId to the input map 15input.put('claimId', claimId); 16 17// Prepare the output map 18Map<String, Object> output = new Map<String, Object>(); 19 20// Prepare the args map 21Map<String, Object> args = new Map<String, Object>(); 22args.put('input', input); 23args.put('output', output); 24 25// Call the 'getClaim' action 26Object result = callable.call('getClaim', args); 27 28// Retrieve the claim data from the result 29ConnectApi.ClaimOutputRepresentation claimData = (ConnectApi.ClaimOutputRepresentation) result; 30 31// Output the claim data to the debug log 32System.debug('Claim Data: ' + JSON.serializePretty(claimData)); 33 34// Check for errors in the output map 35if (output.containsKey('error')) { 36 System.debug('Error: ' + output.get('error')); 37}