---
schema_version: "1"
id: 6eba67223337015cb0eda74d61dcf48d60d248b9a5ade542eb1e241adf14c8df
title: |-
  mapCensusFields(censusId,
        groupCensusFieldMappingInputRepresentation)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_mapCensusFields.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_mapCensusFields.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: e264da7157a01ac31e07bcaaefb8babd73a13ef5dc96d6eb3bd98cd3eaad2aef
description: Map fields on an existing group census to the corresponding quote or contract records without creating new records. Use this method to remap references from quote records to contract records, or from contract records back to quote records, for example after a quote is converted to a contract.
---
# mapCensusFields(censusId, groupCensusFieldMappingInputRepresentation)

Map fields on an existing group census to the corresponding quote or contract records without creating new records. Use this method to remap references from quote records to contract records, or from contract records back to quote records, for example after a quote is converted to a contract.

## API Version

68.0

## Requires Chatter

No

## Signature

public static ConnectApi.GroupCensusFieldMappingRepresentation mapCensusFields(String censusId, ConnectApi.GroupCensusFieldMappingInputRepresentation groupCensusFieldMappingInputRepresentation)

## Parameters

**censusId**

- Type: String
- ID of the group census whose fields are mapped in place.

**groupCensusFieldMappingInputRepresentation**

- Type: [ConnectApi.GroupCensusFieldMappingInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_input_group_census_field_mapping.htm "Input representation of the filters and reference mapping rules used to remap fields on an existing group census in place, without creating new records.")
- Filters and reference mapping rules that remap fields on the existing group census in place, without creating new records.

## Return Value

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

## Usage

Use this method to remap fields on an existing group census in place. Specify the census in censusId. All properties on the input representation are optional.

To process only the member plans that belong to a quote, set quoteId on memberPlanFilter. Set exactly one mapping direction on memberPlanReferenceMapping: use contractId to remap quote line items to contract group plans, or quoteId to remap contract group plans back to quote line items. Don't set both.

The method runs asynchronously and doesn't create new census records. 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 example remaps quote line item references to the matching contract group plans. The groupCensusFilters block is optional and limits processing to member plans of one quote. Set exactly one of contractId or quoteId on memberPlanReferenceMapping to choose the mapping direction.

// Remap quote line item references to the matching contract group plans.

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

// Optional: limit processing to the member plans of one quote.
ConnectApi.MemberPlanFilterInputRepresentation memberPlanFilter =
    new ConnectApi.MemberPlanFilterInputRepresentation();
memberPlanFilter.quoteId = SOURCE\_QUOTE\_ID;

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

// Required: exactly one of contractId / quoteId sets the mapping direction.
ConnectApi.MemberPlanReferenceMappingInputRepresentation memberPlanReferenceMapping =
    new ConnectApi.MemberPlanReferenceMappingInputRepresentation();
memberPlanReferenceMapping.contractId = TARGET\_CONTRACT\_ID;

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

ConnectApi.GroupCensusFieldMappingInputRepresentation input =
    new ConnectApi.GroupCensusFieldMappingInputRepresentation();
input.groupCensusFilters = groupCensusFilters;
input.groupCensusReferenceMappings = groupCensusReferenceMappings;

try {
    ConnectApi.GroupCensusFieldMappingRepresentation result =
        ConnectApi.GroupBenefitsApi.mapCensusFields(CENSUS\_ID, input);

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

This example uses the reverse direction. Set quoteId and omit contractId on memberPlanReferenceMapping to remap contract group plan references back to the matching quote line items.

// Remap contract group plan references back to the matching quote line items.

final String CENSUS\_ID = '0rfxx000000022IAAQ';
final String TARGET\_QUOTE\_ID = '0Q0xx0000004C92CAE';

ConnectApi.MemberPlanReferenceMappingInputRepresentation memberPlanReferenceMapping =
    new ConnectApi.MemberPlanReferenceMappingInputRepresentation();
memberPlanReferenceMapping.quoteId = TARGET\_QUOTE\_ID;   // exactly one direction; do not also set contractId

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

ConnectApi.GroupCensusFieldMappingInputRepresentation input =
    new ConnectApi.GroupCensusFieldMappingInputRepresentation();
input.groupCensusReferenceMappings = groupCensusReferenceMappings;

try {
    ConnectApi.GroupCensusFieldMappingRepresentation result =
        ConnectApi.GroupBenefitsApi.mapCensusFields(CENSUS\_ID, input);

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