postInsuranceCreateCensus(createCensusInputParam, contractId)

Generate a group census from the policies on an existing group benefits contract.

API Version 

67.0

Requires Chatter 

No

Signature 

public static ConnectApi.InsuranceGenerateCensusRepresentation postInsuranceCreateCensus(ConnectApi.InsuranceGenerateCensusInputRepresentation createCensusInputParam, String contractId)

Parameters 

createCensusInputParam

contractId

  • Type: String
  • ID of the insurance contract whose policies are used to generate the group census.

Return Value 

Type: ConnectApi.InsuranceGenerateCensusRepresentation

Usage 

Use this method to generate a group census from the policies on an existing group benefits contract. Specify the contract in contractId and the census type in censusType, such as Enrollment or Quote. Optionally set censusName.

This method runs asynchronously and returns a requestId that you can use to track the job. To retry a failed run, pass that requestId on the next call.

Set policyEffectiveDate in yyyy-MM-dd format to select the policy version. The date must fall between the version’s effectiveFromDate and effectiveToDate. Use filter to limit the census to root contract group plans, contacts, or person accounts. Set shouldGenerateCsv to create a CSV file of the census details. Set shouldIncludeMemberPlans to include insurance plan details for each member.

Check isSuccess, groupCensusId, and requestId on the response. Errors are in the errors property.

Example 

This example starts generating an enrollment census from a contract, filters by person account, and includes member plan details and a CSV file.

1// Generate a group census from the policies on a contract.
2
3final String CONTRACT_ID = '800SB00001I80hWYAR';
4
5// Optional: filter by members and/or root contract group plans.
6ConnectApi.InsuranceCensusFilterInputRepresentation filter =
7    new ConnectApi.InsuranceCensusFilterInputRepresentation();
8filter.objectName = 'PersonAccount';   // Contact or PersonAccount
9filter.recordIds = new List<String>{ '001SB00001xuR1RYAU' };
10// filter.contractGroupPlanIds = new List<String>{ /* CGP ids */ };
11
12ConnectApi.InsuranceGenerateCensusInputRepresentation input =
13    new ConnectApi.InsuranceGenerateCensusInputRepresentation();
14input.censusName = 'apex_Census';
15input.censusType = 'Enrollment';  // e.g. System, Quote, Enrollment, Lead, Renewal
16// input.policyEffectiveDate = '2027-09-01';  // yyyy-MM-dd
17input.shouldGenerateCsv = true;
18input.shouldIncludeMemberPlans = true;
19input.filter = filter;
20// input.requestId = '08Pxx0000000001EAA';  // only to retry a previously failed job
21
22try {
23    ConnectApi.InsuranceGenerateCensusRepresentation result =
24        ConnectApi.InsuranceGroupBenefitsFamily.postInsuranceCreateCensus(input, CONTRACT_ID);
25
26    System.debug('isSuccess: ' + result.isSuccess);
27    System.debug('groupCensusId: ' + result.groupCensusId);
28    System.debug('requestId: ' + result.requestId);
29    System.debug('message: ' + result.message);
30    System.debug('errors: ' + result.errors);
31} catch (Exception e) {
32    System.debug('Error while generating the census: ' + e.getMessage());
33}