endorseDraftInsurancePolicy(insurancePolicyDraftProcessInput, policyId)

Create an endorsement draft for a specific insurance policy by providing the draft input details and the policy ID.

API Version

67.0

Requires Chatter

No

Signature

public static ConnectApi.InsurancePolicyDraftOutputRepresentation endorseDraftInsurancePolicy(ConnectApi.InsurancePolicyDraftInputRepresentation insurancePolicyDraftProcessInput, String policyId)

Parameters

insurancePolicyDraftProcessInput

policyId

  • Type: String
  • ID of the insurance policy for which to create an endorsement draft.

Usage

Use this method to create an endorsement draft for a specific insurance policy. Provide a field value map containing the policy fields to override and the ID of the policy. The response includes the policy ID of the created draft and any errors that occurred during the process.

Example

The Apex example shows how to use the ConnectApi.InsuranceBrokerageFamily.endorseDraftInsurancePolicy() method to create an endorsement draft for a specific insurance policy.

Class Definition

This Apex example shows how to create an endorsement draft for an insurance policy.

global class DraftEndorseConnectDriver {

    global static void callDraftEndorseConnectAPI() {
        Map<String, Object> input = new Map<String, Object>();
        input.put('policyId', '0YTxx000000001dGAA');

        ConnectApi.InsurancePolicyDraftInputRepresentation draftInput = new ConnectApi.InsurancePolicyDraftInputRepresentation();
        Map<String, Object> fields = new Map<String, Object>();
        fields.put('Name', 'Test Apex Draft Endorse');
        fields.put('EffectiveDate', '2026-08-01');
        draftInput.fieldValueMap = fields;

        input.put('policyInput', draftInput);

        Map<String, Object> output = new Map<String, Object>();
        Map<String, Object> args = new Map<String, Object>();
        args.put('input', input);
        args.put('output', output);

        DraftEndorseTestConnectAPI callable = new DraftEndorseTestConnectAPI();
        Object result = callable.call('draftEndorse', args);

        ConnectApi.InsurancePolicyDraftOutputRepresentation policyData =
            (ConnectApi.InsurancePolicyDraftOutputRepresentation) result;
        System.debug('Draft Endorse Policy Data: ' + JSON.serializePretty(policyData));

        if (output.containsKey('error')) {
            System.debug('Error: ' + output.get('error'));
        }
    }
}

Usage Example

Use the DraftEndorseTestConnectAPI class to execute the draftEndorse action and process the result.

public class DraftEndorseTestConnectAPI implements System.Callable {

    public Object call(String action, Map<String, Object> args) {
        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');

        if (action == 'draftEndorse') {
            ConnectApi.InsurancePolicyDraftInputRepresentation draftInput =
                (ConnectApi.InsurancePolicyDraftInputRepresentation) inputMap.get('policyInput');
            String policyId = (String) inputMap.get('policyId');
            System.debug('Start of Connect API call to draft endorse policy: ' + policyId);

            ConnectApi.InsurancePolicyDraftOutputRepresentation policyData;
            try {
                policyData = ConnectApi.InsuranceBrokerageFamily.endorseDraftInsurancePolicy(draftInput, policyId);
                System.debug('Draft endorsement created successfully: ' + policyData);
                outputMap.put('policyData', policyData);
            } catch (Exception e) {
                System.debug('Error while creating draft endorsement: ' + e.getMessage());
                outputMap.put('error', e.getMessage());
            }
            return policyData;
        }

        return null;
    }
}

// Execute
DraftEndorseConnectDriver.callDraftEndorseConnectAPI();