---
schema_version: "1"
id: a79261225a4fd1bbc7eded901870cc882a41b15a7e91233b12dfce53b84573cf
title: |-
  deepCloneGroupCensus(groupCensusDeepCloneInputRepresentation,
        censusId)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_deepCloneGroupCensus.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_deepCloneGroupCensus.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0ad5bb5a594baf40d343244e843051c055a2ce85603a761a44a1c08aee3bca20
description: Clone a group census and its hierarchy, including members, member plans, and plan attributes. Use this method to copy quoting-phase census data into an enrollment-type census, apply field-level overrides, and optionally filter or remap member plan references.
---
# deepCloneGroupCensus(groupCensusDeepCloneInputRepresentation, censusId)

Clone a group census and its hierarchy, including members, member plans, and plan attributes. Use this method to copy quoting-phase census data into an enrollment-type census, apply field-level overrides, and optionally filter or remap member plan references.

## API Version

68.0

## Requires Chatter

No

## Signature

public static ConnectApi.GroupCensusDeepCloneRepresentation deepCloneGroupCensus(ConnectApi.GroupCensusDeepCloneInputRepresentation groupCensusDeepCloneInputRepresentation, String censusId)

## Parameters

**groupCensusDeepCloneInputRepresentation**

- Type: [ConnectApi.GroupCensusDeepCloneInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_input_group_census_deep_clone.htm "Input representation of the details to clone a group census hierarchy, including optional filters, reference mappings, field overrides, and a custom context definition.")
- Details of the clone operation, including optional filters, reference mappings, field overrides, and a custom context definition.

**censusId**

- Type: String
- ID of the source group census to clone.

## Return Value

Type: [ConnectApi.GroupCensusDeepCloneRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_output_group_census_deep_clone.htm "Output representation that's returned after a group census deep-clone request is processed. The response includes the asynchronous request ID and any errors that occurred while validating or scheduling the job.")

## Usage

Use this method to clone a group census and its hierarchy, including members, member plans, and plan attributes. Specify the source census in censusId. All properties on the input representation are optional.

To clone only the member plans that belong to a quote, set quoteId on memberPlanFilter. To remap those plans from quote line items to contract group plans, set contractId on memberPlanReferenceMapping. To stamp new field values on the cloned census, put field API names and values in targetGroupCensusOverrides.

To clone the full hierarchy with no filters, mappings, or overrides, pass an empty input representation. The method runs asynchronously. Use the requestId in the response to track the job. Errors that occur while validating or scheduling the job are in the errors property.

## Example

This is an example to clone a group census from Apex code. It limits the clone to member plans on a specified quote, remaps those quote line item references to contract group plans, and stamps name and status values on the target census.

// Clone a group census hierarchy, optionally filtering member plans,
// remapping references, and stamping field values on the target census.

final String CENSUS\_ID = '0rfxx000000022IAAQ';
final String SOURCE\_QUOTE\_ID = '0Q0xx0000004C92CAE';
final String TARGET\_CONTRACT\_ID = '800xx000000gVN3AAM';

// Optional: scope the clone to one quote's member plans.
ConnectApi.MemberPlanFilterInputRepresentation memberPlanFilter =
    new ConnectApi.MemberPlanFilterInputRepresentation();
memberPlanFilter.quoteId = SOURCE\_QUOTE\_ID;

ConnectApi.GroupCensusFiltersInputRepresentation groupCensusFilters =
    new ConnectApi.GroupCensusFiltersInputRepresentation();
groupCensusFilters.memberPlanFilter = memberPlanFilter;

// Optional: remap quote line items to contract group plans.
// Provide exactly the direction you want.
ConnectApi.MemberPlanReferenceMappingInputRepresentation memberPlanReferenceMapping =
    new ConnectApi.MemberPlanReferenceMappingInputRepresentation();
memberPlanReferenceMapping.contractId = TARGET\_CONTRACT\_ID;

ConnectApi.GroupCensusReferenceMappingsInputRepresentation groupCensusReferenceMappings =
    new ConnectApi.GroupCensusReferenceMappingsInputRepresentation();
groupCensusReferenceMappings.memberPlanReferenceMapping = memberPlanReferenceMapping;

ConnectApi.GroupCensusDeepCloneInputRepresentation input =
    new ConnectApi.GroupCensusDeepCloneInputRepresentation();
input.groupCensusFilters = groupCensusFilters;
input.groupCensusReferenceMappings = groupCensusReferenceMappings;
input.targetGroupCensusOverrides = new Map<String, Object\>{
    'Name' => 'Apex DeepClone Census',
    'Status' => 'Draft'
};
// input.contextDefId = 'My\_Custom\_DeepClone\_ContextDef';   // optional

try {
    ConnectApi.GroupCensusDeepCloneRepresentation result =
        ConnectApi.GroupBenefitsApi.deepCloneGroupCensus(input, CENSUS\_ID);

    System.debug('requestId: ' + result.requestId);
    System.debug('errors: ' + result.errors);
} catch (Exception e) {
    System.debug('Error while cloning the group census: ' + e.getMessage());
}

This example clones the full hierarchy with no filters, mappings, or overrides.

// Clone the full census hierarchy with no filters, mappings, or overrides.

final String CENSUS\_ID = '0rfxx000000022IAAQ';

ConnectApi.GroupCensusDeepCloneInputRepresentation input =
    new ConnectApi.GroupCensusDeepCloneInputRepresentation();

try {
    ConnectApi.GroupCensusDeepCloneRepresentation result =
        ConnectApi.GroupBenefitsApi.deepCloneGroupCensus(input, CENSUS\_ID);

    System.debug('requestId: ' + result.requestId);
    System.debug('errors: ' + result.errors);
} catch (Exception e) {
    System.debug('Error while cloning the group census: ' + e.getMessage());
}