Newer Version Available

This content describes an older version of this product. View Latest

OutOfSequenceEndorsePolicy(OutOfSequenceEndorsePolicyInput, policyId)

Create an out-of-sequence endorsement for an insurance policy.

API Version

65.0

Requires Chatter

No

Signature

public static ConnectApi.OutOfSequenceEndorsePolicyOutputRepresentation OutOfSequenceEndorsePolicy(ConnectApi.OutOfSequenceEndorsePolicyInputRepresentation OutOfSequenceEndorsePolicyInput, String policyId)

Parameters

OutOfSequenceEndorsePolicyInput
Type: ConnectApi.OutOfSequenceEndorsePolicyInputRepresentation
Details to create the out-of-sequence endorsement.
policyId
Type: String
ID of the insurance policy to create the out-of-sequence endorsement for.

Example

Here's an example of how to invoke the Out-of-Sequence Policy API by using Apex.

1/*
2 * Out of Sequence Policy Endorsement Service using Connect API
3 *
4 * IMPORTANT: Out-of-sequence endorsement is an asynchronous process and returns a job identifier
5 * for tracking the request.
6 */
7public with sharing class OutOfSequenceEndorsement implements System.Callable {
8 
9 public Object call(String action, Map<String, Object> args) {
10 // Retrieve the input and output maps from the arguments
11 Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
12 Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
13 
14 // Check the action type
15 if (action == 'outOfSequenceEndorsePolicy') {
16 System.debug('Start of connect API call to out of sequence endorse policy');
17 
18 // Get input parameters from the input map
19 String policyId = (String) inputMap.get('policyId');
20 String effectiveDate = (String) inputMap.get('effectiveDate');
21 String contextId = (String) inputMap.get('contextId');
22 
23 System.debug('Policy ID: ' + policyId);
24 System.debug('Effective Date: ' + effectiveDate);
25 System.debug('Context ID: ' + contextId);
26 
27 // Initialize the job identifier
28 String jobIdentifier = null;
29 
30 // Validate required parameters
31 if (String.isBlank(policyId)) {
32 System.debug('ERROR: Policy ID is required');
33 outputMap.put('error', 'Policy ID is required');
34 return null;
35 }
36 if (String.isBlank(effectiveDate)) {
37 System.debug('ERROR: Effective Date is required');
38 outputMap.put('error', 'Effective Date is required');
39 return null;
40 }
41 if (String.isBlank(contextId)) {
42 System.debug('ERROR: Context ID is required');
43 outputMap.put('error', 'Context ID is required');
44 return null;
45 }
46 
47 try {
48 
49 // Step 1: Create OOSE input using the provided context ID
50 ConnectApi.OutOfSequenceEndorsePolicyInputRepresentation policyInput = 
51 new ConnectApi.OutOfSequenceEndorsePolicyInputRepresentation();
52
53 // Populate fields for InsurancePolicyInputRepresentation 
54 ConnectApi.InsurancePolicyInputRepresentation insurancePolicy = 
55 new ConnectApi.InsurancePolicyInputRepresentation();
56 insurancePolicy.policyName = 'Lisa Auto Policy';
57 insurancePolicy.policyNumber = 'Lisa Auto Policy';
58 policyInput.insurancePolicy = insurancePolicy;
59
60 // Populate transaction record
61 ConnectApi.InsurancePolicyTransactionInputRepresentation transactionRecord = 
62 new ConnectApi.InsurancePolicyTransactionInputRepresentation();
63 transactionRecord.name = 'Custom OOSE Transaction';
64 policyInput.transactionRecord = transactionRecord;
65
66 // Set the effective date for the out of sequence endorsement
67 policyInput.effectiveDate = effectiveDate;
68 
69 // Use the provided context ID
70 policyInput.contextId = contextId;
71
72 // Set field sets
73 ConnectApi.AdditionalFieldsFieldSetInputRepresentation fieldSetIds = 
74 new ConnectApi.AdditionalFieldsFieldSetInputRepresentation();
75 fieldSetIds.policyFieldSetId = '0IXZM0000008P684AE'; // Replace with your policy field set ID
76 fieldSetIds.assetFieldSetId = '0IXZM0000004DDC4A2'; // Replace with your asset field set ID
77 fieldSetIds.participantFieldSetId = '0IXZM0000004DDH4A2'; // Replace with your participant field set ID
78 fieldSetIds.coverageFieldSetId = '0IXZM0000008P6D4AU'; // Replace with your coverage field set ID
79 policyInput.fieldSetIds = fieldSetIds;
80 
81 // Step 2: Execute OOSE with the provided context ID
82 System.debug('Executing OOSE with context ID: ' + contextId);
83 
84 // Call the Connect API directly - OOSE is ASYNCHRONOUS and returns a job identifier
85 ConnectApi.OutOfSequenceEndorsePolicyOutputRepresentation ooseResult =
86 ConnectApi.InsurancePolicyAdminFamily.outOfSequenceEndorsePolicy(policyInput, policyId);
87
88 // Get the job identifier
89 jobIdentifier = ooseResult.jobIdentifier;
90 
91 // Log success
92 System.debug('Out-of-sequence endorsement job started successfully. Job ID: ' + jobIdentifier);
93 System.debug('Policy: ' + policyId + ' | Context: ' + contextId + ' | Effective Date: ' + effectiveDate);
94 
95 // Put the job identifier in the output map
96 outputMap.put('jobIdentifier', jobIdentifier);
97 outputMap.put('ooseResult', ooseResult);
98 
99 } catch (Exception e) {
100 System.debug('Error while executing out-of-sequence endorsement: ' + e.getMessage());
101 outputMap.put('error', e.getMessage());
102 }
103 
104 // Return the job identifier
105 return jobIdentifier;
106 }
107 
108 // If the action is not recognized, return null
109 return null;
110 }
111}
112
113/*
114 * USAGE EXAMPLE:
115 * Copy and paste this code into Developer Console Execute Anonymous Window
116 */
117
118// Create instance of the callable class
119OutOfSequenceEndorsement callable = new OutOfSequenceEndorsement();
120
121// Prepare the input arguments
122Map<String, Object> input = new Map<String, Object>();
123input.put('policyId', '0YTxx00000000MbGAI'); // Replace with your policy ID  
124input.put('effectiveDate', '2025-06-01'); // Replace with your desired effective date
125input.put('contextId', 'your-context-id-here'); // Replace with your context ID
126
127// Prepare the output map
128Map<String, Object> output = new Map<String, Object>();
129
130// Prepare the args map
131Map<String, Object> args = new Map<String, Object>();
132args.put('input', input);
133args.put('output', output);
134
135// Call the 'outOfSequenceEndorsePolicy' action
136Object result = callable.call('outOfSequenceEndorsePolicy', args);
137
138// Retrieve the job identifier from the result
139String jobIdentifier = (String) result;
140
141// Output the job identifier to the debug log
142System.debug('Job Identifier: ' + jobIdentifier);
143
144// Check for errors in the output map
145if (output.containsKey('error')) {
146    System.debug('Error: ' + output.get('error'));
147} else if (output.containsKey('jobIdentifier')) {
148    System.debug('SUCCESS: OOSE job started with ID: ' + output.get('jobIdentifier'));
149    System.debug('Monitor this job ID for completion status.');
150}