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
Filters and reference mapping rules that remap fields on the existing group census in place, without creating new records.

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.

1// Remap quote line item references to the matching contract group plans.
2
3final String CENSUS_ID = '0rfxx000000022IAAQ';
4final String TARGET_CONTRACT_ID = '800xx000000gVN3AAM';
5final String SOURCE_QUOTE_ID = '0Q0xx0000004C92CAE';
6
7// Optional: limit processing to the member plans of one quote.
8ConnectApi.MemberPlanFilterInputRepresentation memberPlanFilter =
9    new ConnectApi.MemberPlanFilterInputRepresentation();
10memberPlanFilter.quoteId = SOURCE_QUOTE_ID;
11
12ConnectApi.GroupCensusFiltersInputRepresentation groupCensusFilters =
13    new ConnectApi.GroupCensusFiltersInputRepresentation();
14groupCensusFilters.memberPlanFilter = memberPlanFilter;
15
16// Required: exactly one of contractId / quoteId sets the mapping direction.
17ConnectApi.MemberPlanReferenceMappingInputRepresentation memberPlanReferenceMapping =
18    new ConnectApi.MemberPlanReferenceMappingInputRepresentation();
19memberPlanReferenceMapping.contractId = TARGET_CONTRACT_ID;
20
21ConnectApi.GroupCensusReferenceMappingsInputRepresentation groupCensusReferenceMappings =
22    new ConnectApi.GroupCensusReferenceMappingsInputRepresentation();
23groupCensusReferenceMappings.memberPlanReferenceMapping = memberPlanReferenceMapping;
24
25ConnectApi.GroupCensusFieldMappingInputRepresentation input =
26    new ConnectApi.GroupCensusFieldMappingInputRepresentation();
27input.groupCensusFilters = groupCensusFilters;
28input.groupCensusReferenceMappings = groupCensusReferenceMappings;
29
30try {
31    ConnectApi.GroupCensusFieldMappingRepresentation result =
32        ConnectApi.GroupBenefitsApi.mapCensusFields(CENSUS_ID, input);
33
34    System.debug('requestId: ' + result.requestId);
35    System.debug('errors: ' + result.errors);
36} catch (Exception e) {
37    System.debug('Error while mapping group census fields: ' + e.getMessage());
38}

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.

1// Remap contract group plan references back to the matching quote line items.
2
3final String CENSUS_ID = '0rfxx000000022IAAQ';
4final String TARGET_QUOTE_ID = '0Q0xx0000004C92CAE';
5
6ConnectApi.MemberPlanReferenceMappingInputRepresentation memberPlanReferenceMapping =
7    new ConnectApi.MemberPlanReferenceMappingInputRepresentation();
8memberPlanReferenceMapping.quoteId = TARGET_QUOTE_ID;   // exactly one direction; do not also set contractId
9
10ConnectApi.GroupCensusReferenceMappingsInputRepresentation groupCensusReferenceMappings =
11    new ConnectApi.GroupCensusReferenceMappingsInputRepresentation();
12groupCensusReferenceMappings.memberPlanReferenceMapping = memberPlanReferenceMapping;
13
14ConnectApi.GroupCensusFieldMappingInputRepresentation input =
15    new ConnectApi.GroupCensusFieldMappingInputRepresentation();
16input.groupCensusReferenceMappings = groupCensusReferenceMappings;
17
18try {
19    ConnectApi.GroupCensusFieldMappingRepresentation result =
20        ConnectApi.GroupBenefitsApi.mapCensusFields(CENSUS_ID, input);
21
22    System.debug('requestId: ' + result.requestId);
23    System.debug('errors: ' + result.errors);
24} catch (Exception e) {
25    System.debug('Error while mapping group census fields: ' + e.getMessage());
26}