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.
postInsuranceCreateAccounts(createAccountsInputParam, createPortalUsers)
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.InsuranceAccountsAndUsersCreationRepresentation postInsuranceCreateAccounts(ConnectApi.InsuranceAccountsAndUsersCreationInputRepresentation createAccountsInputParam, Boolean createPortalUsers)
Parameters
- createAccountsInputParam
- Type: ConnectApi.InsuranceAccountsAndUsersCreationInputRepresentation
- Details to create person accounts.
- createPortalUsers
- Type: Boolean
- Specifies whether to create portal users for the new person accounts (true) or not (false). The default is false.
Return Value
Type: ConnectApi.InsuranceAccountsAndUsersCreationRepresentation
Example
Here's an example of how to invoke the Create Accounts API from Apex code.
1// Accounts and (optional) Portal Users creation via Connect API (simple version)
2
3// 1) Create the top-level input
4ConnectApi.InsuranceAccountsAndUsersCreationInputRepresentation input =
5 new ConnectApi.InsuranceAccountsAndUsersCreationInputRepresentation();
6
7// Provide either a Group Census Id OR a list of Group Census Member Ids
8
9// Option A: Use the Group Census Id (creates accounts for all eligible members)
10// input.groupCensusId = '0rfSG0000000vw7YAA';
11
12// Option B: Or specify specific Group Census Member Ids
13input.groupCensusMemberIdList = new List<String>{ '0r6SG0000008uTRYAY'};
14
15// Optional: Person Account Record Type Name
16input.personAccountRecordType = 'Person Account';
17
18// Optional: Matching keys (used to find existing Person Accounts before creating new ones)
19// input.matchingKeyList = new List<String>{ 'Email', 'ExternalId__c' };
20
21// Optional: Field mappings from Group Census Member fields -> Account fields
22// Example: map census FirstName/LastName to Person Account fields
23// input.fieldMappings = new Map<String, String>{
24// 'FirstName' => 'FirstName',
25// 'LastName' => 'LastName',
26// 'Email' => 'PersonEmail'
27// };
28
29// Optional: Provide portal user defaults (only applied if createPortalUsers = true)
30ConnectApi.PortalUserCreationInputRepresentation userDefaults =
31 new ConnectApi.PortalUserCreationInputRepresentation();
32userDefaults.profileId = '00eSG00000JZg4t';
33// userDefaults.localeSidKey = 'en_US';
34// userDefaults.timeZoneSidKey = 'America/Los_Angeles';
35// userDefaults.languageLocaleKey = 'en_US';
36// userDefaults.emailEncodingKey = 'UTF-8';
37input.userDetails = userDefaults;
38
39// 2) Execute the POST API
40Boolean createPortalUsers = true; // set false to only create accounts
41
42try {
43 ConnectApi.InsuranceAccountsAndUsersCreationRepresentation result =
44 ConnectApi.InsuranceGroupBenefitsFamily.postInsuranceCreateAccounts(
45 input,
46 createPortalUsers
47 );
48
49 System.debug('Accounts and Users creation result: ' + JSON.serializePretty(result));
50} catch (Exception e) {
51 System.debug('Error during accounts/users creation: ' + e.getMessage());
52}