renewInsurancePolicy(insurancePolicyProcessInput, policyId)
API Version
63.0
Requires Chatter
No
Signature
public static ConnectApi.InsurancePolicyProcessOutputRepresentation renewInsurancePolicy(ConnectApi.InsurancePolicyRenewInputRepresentation insurancePolicyProcessInput, String policyId)
1ConnectApi.InsuranceBrokerageFamily, renewInsurancePolicy, [ConnectApi.InsurancePolicyRenewInputRepresentation, String], ConnectApi.InsurancePolicyProcessOutputRepresentationParameters
- insurancePolicyProcessInput
- Type: ConnectApi.InsurancePolicyRenewInputRepresentation
- Input representation details of the request to renew an insurance policy.
- policyId
- Type: String
- ID of the insurance policy that's to be renewed.
Return Value
Usage
The Insurance Policy Renewal API takes a JSON input that contains the insurance policy ID that must be renewed along with the fieldValueMap details. The API submits the request to a queue, creates a policy, along with child records by using the context definition selected in setup. The service also overrides the fieldValueMap in the new policy for the policy ID passed in the request. Users receive success and failure notifications on request completion.
Keep these considerations in mind when you use this method.
- The RenewedFromPolicyId value of the new policy is set to the current policy ID and IsRenewedPolicy field of the new policy is set to true.
- The fieldValueMap expects the keys to be API name and is case-sensitive.
Example
The Apex example shows how to use the ConnectApi.InsuranceBrokerageFamily.renewInsurancePolicy() method to reinstate a previously canceled insurance policy.
- Class Definition
- This Apex example shows how to renew an insurance policy.
-
1global class RenewConnectDriver { 2 3 global static void callRenewConnectAPI() { 4 Map<String, Object> input = new Map<String, Object>(); 5 input.put('policyId', '0YTxx000000001dGAA'); 6 7 ConnectApi.InsurancePolicyRenewInputRepresentation policyInput = new ConnectApi.InsurancePolicyRenewInputRepresentation(); 8 Map<String, Object> fields = new Map<String, Object>(); 9 fields.put('Name', 'Test Apex Renew'); 10 policyInput.fieldValueMap = fields; 11 policyInput.sameCarrier = true; 12 13 input.put('policyInput', policyInput); 14 15 Map<String, Object> output = new Map<String, Object>(); 16 Map<String, Object> args = new Map<String, Object>(); 17 args.put('input', input); 18 args.put('output', output); 19 20 RenewTestConnectAPI callable = new RenewTestConnectAPI(); 21 Object result = callable.call('renew', args); 22 23 ConnectApi.InsurancePolicyProcessOutputRepresentation policyData = 24 (ConnectApi.InsurancePolicyProcessOutputRepresentation) result; 25 System.debug('Renew Policy Data: ' + JSON.serializePretty(policyData)); 26 27 if (output.containsKey('error')) { 28 System.debug('Error: ' + output.get('error')); 29 } 30 } 31} - Usage Example
- Use the RenewTestConnectAPI class to execute the renew action and process the result.
-
1public class RenewTestConnectAPI implements System.Callable { 2 3 public Object call(String action, Map<String, Object> args) { 4 Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); 5 Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); 6 7 if (action == 'renew') { 8 ConnectApi.InsurancePolicyRenewInputRepresentation policyInput = 9 (ConnectApi.InsurancePolicyRenewInputRepresentation) inputMap.get('policyInput'); 10 String policyId = (String) inputMap.get('policyId'); 11 System.debug('Start of Connect API call to renew policy: ' + policyId); 12 13 ConnectApi.InsurancePolicyProcessOutputRepresentation policyData; 14 try { 15 policyData = ConnectApi.InsuranceBrokerageFamily.renewInsurancePolicy(policyInput, policyId); 16 System.debug('Policy renewed successfully: ' + policyData); 17 outputMap.put('policyData', policyData); 18 } catch (Exception e) { 19 System.debug('Error while renewing policy: ' + e.getMessage()); 20 outputMap.put('error', e.getMessage()); 21 } 22 return policyData; 23 } 24 25 return null; 26 } 27} 28 29// Execute 30RenewConnectDriver.callRenewConnectAPI();