patchInsuranceUpdateCensus(updateCensusInputParam, contractId)
API Version
68.0
Requires Chatter
No
Signature
public static ConnectApi.InsuranceRefreshCensusRepresentation patchInsuranceUpdateCensus(ConnectApi.InsuranceRefreshCensusInputRepresentation updateCensusInputParam, String contractId)
Parameters
- updateCensusInputParam
- Type: ConnectApi.InsuranceRefreshCensusInputRepresentation
- Group census ID, date range, optional filters, and update options used to refresh the group census.
- contractId
- Type: String
- ID of the insurance contract whose policy enrollments and endorsements are used to update the group census.
Return Value
Usage
Use this method to update a group census from policy enrollments and endorsements on an existing group benefits contract. Specify the contract in contractId and the census in groupCensusId. Set startDate and endDate in yyyy-MM-dd format to define the enrollment and endorsement window. Set policyEffectiveDate in the same format to select the policy version. The date must fall between the version's effectiveFromDate and effectiveToDate.
This method runs asynchronously and returns a requestId that you can use to track the job. To retry a failed run, pass that requestId with the same groupCensusId.
Use filter to limit the update to root contract group plans, contacts, or person accounts. Set shouldGenerateCSV to create a CSV file of the updated census details. Set shouldIncludeMemberPlans to include insurance plan details for each member. To stamp additional field values on group census members, add items to groupCensusAdditionalFields.
Check isSuccess, groupCensusId, and requestId on the response. Errors are in the errors property.
Example
This example starts updating a group census from a contract for a date range, filters by person account, stamps an additional census field, and includes member plan details and a CSV file.
1// Update a group census from policy enrollments and endorsements on a contract.
2
3final String CONTRACT_ID = '800SB00001HNnddYAD';
4
5// Optional: filter by members and/or root contract group plans.
6ConnectApi.InsuranceCensusFilterInputRepresentation filter =
7 new ConnectApi.InsuranceCensusFilterInputRepresentation();
8filter.objectName = 'PersonAccount';
9filter.recordIds = new List<String>{ '001SB00001wg2zZYAQ' };
10// filter.contractGroupPlanIds = new List<String>{ /* optional: root contract group plan IDs */ };
11
12ConnectApi.InsuranceApexStringRepresentation sourceSystem =
13 new ConnectApi.InsuranceApexStringRepresentation();
14sourceSystem.key = 'SourceSystemName';
15sourceSystem.value = 'new';
16
17ConnectApi.InsuranceRefreshCensusInputRepresentation input =
18 new ConnectApi.InsuranceRefreshCensusInputRepresentation();
19input.groupCensusId = '0rfSB000000505pYAA';
20input.startDate = '2026-07-04';
21input.endDate = '2026-08-10';
22input.policyEffectiveDate = '2026-12-12';
23input.shouldIncludeMemberPlans = true;
24input.shouldGenerateCSV = true;
25input.filter = filter;
26input.groupCensusAdditionalFields = new List<ConnectApi.InsuranceApexStringRepresentation>{
27 sourceSystem
28};
29// input.requestId = '08Pxx0000000001EAA'; // only to retry records that failed in a previous run
30
31try {
32 ConnectApi.InsuranceRefreshCensusRepresentation result =
33 ConnectApi.InsuranceGroupBenefitsFamily.patchInsuranceUpdateCensus(input, CONTRACT_ID);
34
35 System.debug('isSuccess: ' + result.isSuccess);
36 System.debug('groupCensusId: ' + result.groupCensusId);
37 System.debug('requestId: ' + result.requestId);
38 System.debug('message: ' + result.message);
39 System.debug('errors: ' + result.errors);
40} catch (Exception e) {
41 System.debug('Error while updating the census: ' + e.getMessage());
42}