Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
postInsuranceAddMemberPlans(insuranceAddMemberPlansInputRepresentation, memberId)
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.InsuranceAddMemberPlansOutputRepresentation postInsuranceAddMemberPlans(ConnectApi.InsuranceAddMemberPlansInputRepresentation insuranceAddMemberPlansInputRepresentation, String memberId)
Parameters
- insuranceAddMemberPlansInputRepresentation
- Type: ConnectApi.InsuranceAddMemberPlansInputRepresentation
- Details to add plans.
- memberId
- Type: String
- ID of the group census member to add plans for.
Return Value
Type: ConnectApi.InsuranceAddMemberPlansOutputRepresentation
Example
Here's an example of how to invoke the Insurance Add Member Plans API from Apex code.
1// Add Member Plan(s) for a Group Census Member via Connect API (simple version)
2
3// 1) Create the top-level input
4ConnectApi.InsuranceAddMemberPlansInputRepresentation input = new ConnectApi.InsuranceAddMemberPlansInputRepresentation();
5
6// 2) Build one or more member plan entries
7// Required: contractGroupPlanId (the plan you want to add for the member)
8// Tip: You don't need to set groupCensusMemberId on each plan here because it's passed as a separate argument.
9List<ConnectApi.GroupCensusMemberPlanInputRepresentation> plans = new List<ConnectApi.GroupCensusMemberPlanInputRepresentation>();
10
11ConnectApi.GroupCensusMemberPlanInputRepresentation plan1 = new ConnectApi.GroupCensusMemberPlanInputRepresentation();
12plan1.contractGroupPlanId = '0rgxx000000003kAAA'; // e.g., a2Cxx0000001234AAA
13// Optional fields:
14// plan1.name = 'Employee Medical Gold';
15// plan1.id = 'existingMemberPlanIdIfUpdating'; // not used for add
16plans.add(plan1);
17
18ConnectApi.GroupCensusMemberPlanInputRepresentation plan2 = new ConnectApi.GroupCensusMemberPlanInputRepresentation();
19plan2.contractGroupPlanId = '0rgxx000000003jAAA';
20// If adding more plans, repeat and add to the list
21plans.add(plan2);
22
23// 3) Wrap plans list into the input
24// The wrapper expects a list container object
25input.groupCensusMemberPlans = plans;
26
27// 4) Execute the POST API
28// URL param is the Group Census Member Id the plans will be added to
29String memberId = '0r6xx00000009CzAAI';
30
31try {
32 ConnectApi.InsuranceAddMemberPlansOutputRepresentation result =
33 ConnectApi.InsuranceGroupBenefitsFamily.postInsuranceAddMemberPlans(input, memberId);
34
35 System.debug('Add Member Plans result: ' + JSON.serializePretty(result));
36} catch (Exception e) {
37 System.debug('Error while adding member plans: ' + e.getMessage());
38}