You are here:
InsCensusService:convertLeadAndCreateCensus
Use this service to extend the Lead Conversion Salesforce feature, allowing users to include Lead census information and map this data to the Vlocity Group Account Census objects while converting the Lead.
Method: convertLeadAndCreateCensus
How It Works
When the convertLeadtoAccount option is used to convert a lead,
the service converts InsuredGroupCensus__c to
GroupCensus__c and InsuredGroupCensusMembers to
GroupCensusMembers__c.
This service uses two objects:
-
InsuredGroupCensus__c—This object captures the census at the lead stage. The census provides a statistical snapshot of eligible members of a group (such as employees) and their dependents. This census data is used to score leads in a marketing context.
If the Lead is converted to an Account (using the Salesforce Lead to Account conversion process), the census can then be converted to the Account Census Vlocity objects as well and be used in quote ratings.
-
InsuredGroupCensusMember__c—This object captures census members at the lead stage. It contains specific personal information about a census member (such as an employee) or dependent that is used by the insurance company to estimate the health care costs for the group.
This object is the master-detail child object of the Insured Group Census object, above. This census data is only used for healthcare cost estimation after the corresponding
GroupCensus__candGroupCensusMember__cdata is created from these sources (that is,InsuredGroupCensus__candInsuredGroupCensusMember__c.
So here's how the service works:
-
The service takes the
insuredCensusIdas an Input and uses it to retrieve theInsuredGroupCensus__c object. -
If the
convertLeadToAccountremote option is true, it converts the attachedLeadId__cinto an Account; otherwise, it requires theaccountIdas an input. -
The service then creates a
GroupCensus__c, with a type Group, using theInsuredGroupCensus__c.Vlocity fieldMappers are used here. There are two maps for this service: a map for
InsuredGroupCensus__ctoGroupCensus__c; and a map forInsuredGroupCensusMember__ctoGroupCensusMember__c.If the mapping configuration is not present, the
GroupCensus__crecord is created based on specific fields from theInsuredGroupCensus__cobject.Mapping for
InsuredGroupCensusMember__ctoGroupCensusMember__cis as follows:InsuredGroupCensusMember__c
GroupCensusMember__c
Name
Name
FirstName__c
FirstName__c
LastName__c
LastName__c
BirthDate__c
BirthDate__c
isPrimaryMember__c
isPrimaryMember__c
NumberOfDependents__c
NumberOfDependents__c
Gender__c
Gender__c
Id
MemberIdentifier__c
RelatedInsuredCensusMemberId__c
PrimaryMemberIdentifier__c
Mapping for
InsuredGroupCensus__ctoGroupCensus__cis as follows:InsuredGroupCensus__c
GroupCensus__c
Name
Name
EffectiveStartDate__c
EffectiveStartDate__c
EffectiveEndDate__c
EffectiveEndDate__c
CensusSource__c
CensusSource__c
AccountId From Inputs Or Converted From Lead
GroupId__c
CensusType__c
Group
RecordTypeName of InsuredGroupCensus__c to get RecordTypeId of GroupCensus__c then map that ID as RecordTypeId in GroupCensus__c.
-
The service then uses the
GroupCensus__cID, as generated in the previous step, to createGroupCensusMember__crecords from the sourceInsuredGroupCensusMember__crecords. TheGroupCensusMember__crecords are created as children of theGroupCensus__crecord, as created in the previous step.NoteThe
RelatedInsuredGroupCensusMemberId__cfield must be properly set in theInsuredGroupCensusMember__crecords. This ensures that the mapping from dependent to primary works as expected.For every dependent, this must be set to the ID of the
InsuredGroupCensusMember__crecord which represents the corresponding primary member. -
The service then maps the dependents using the aforementioned fields.
If the following custom field mappings do not exist, they're mapped explicitly in the code:
InsuredGroupCensusMember_c |
GroupCensusMember_c |
|---|---|
Id |
MemberIdentifier__c |
IsPrimaryMember_c |
IsPrimaryMember_c |
RelatedInsuredCensusMemberId_c |
PrimaryMemberIdentifier_c |
NumberOfDependents_c |
NumberOfDependents_c |
Inputs
Option |
Description |
|---|---|
|
Required. Id of the |
|
Optional. Id of the Account the Census will be attached to. This is ignored if the boolean value of
|
Remote Options
Option |
Description |
|---|---|
|
Boolean value. If true, convert the lead attached to the
|
|
String. String name of the Account Record type. |
Input JSON
Here's a sample input JSON using accountId and
insuredCensusId.
{
"ContextId": "",
"timeStamp": "2020-03-25T07:42:51.868Z",
"userId": "0056g000003cVLZAA2",
"userName": "ins-test09@vlocity.com",
"userProfile": "System Administrator",
"userTimeZone": -420,
"userCurrencyCode": "USD",
"sfdcIFrameOrigin": "https://ins-test09-dev-ed--instest09.visualforce.com",
"sfdcIFrameHost": "web",
"layout": "lightning",
"isdtp": "p1",
"id": "a236g000000NAibAAG",
"vlcPersistentComponent": {},
"accountId": "0016g00000Ir5LsAAJ",
"insuredCensusId": "a5l6g000000RYasAAG"
}Output JSON
Here is a sample output JSON, with the GroupCensus__c information
and the GroupCensusMember__c list with its information.
{
"ContextId": "",
"timeStamp": "2020-03-25T07:42:51.868Z",
"userId": "0056g000003cVLZAA2",
"userName": "ins-test09@vlocity.com",
"userProfile": "System Administrator",
"userTimeZone": -420,
"userCurrencyCode": "USD",
"sfdcIFrameOrigin": "https://ins-test09-dev-ed--instest09.visualforce.com",
"sfdcIFrameHost": "web",
"layout": "lightning",
"isdtp": "p1",
"id": "a236g000000NAibAAG",
"vlcPersistentComponent": {},
"accountId": "0016g00000Ir5LsAAJ",
"insuredCensusId": "a5l6g000000RYasAAG",
"censusMembers": [
{
"attributes": {
"type": "instest09__GroupCensusMember__c",
"url": "/services/data/v48.0/sobjects/instest09__GroupCensusMember__c/a4N6g0000013CP4EAM"
},
"Name": "Primary 1",
"instest09__CensusId__c": "a4O6g000000AuJBEA0",
"instest09__FirstName__c": "Primary",
"instest09__LastName__c": "Primary",
"instest09__Birthdate__c": "2020-03-03",
"instest09__IsPrimaryMember__c": true,
"instest09__MemberType__c": "Full Time",
"instest09__NumberOfDependents__c": 0,
"instest09__Gender__c": "Male",
"instest09__MemberIdentifier__c": "a5k6g000000T7REAA0",
"instest09__PrimaryMemberIdentifier__c": null,
"Id": "a4N6g0000013CP4EAM"
},
{
"attributes": {
"type": "instest09__GroupCensusMember__c",
"url": "/services/data/v48.0/sobjects/instest09__GroupCensusMember__c/a4N6g0000013CP5EAM"
},
"Name": "Dependent Child",
"instest09__CensusId__c": "a4O6g000000AuJBEA0",
"instest09__FirstName__c": "Child 1",
"instest09__LastName__c": "Chila 1",
"instest09__Birthdate__c": "2020-03-12",
"instest09__IsPrimaryMember__c": true,
"instest09__MemberType__c": null,
"instest09__NumberOfDependents__c": 0,
"instest09__Gender__c": "Male",
"instest09__MemberIdentifier__c": "a5k6g000000T7RTAA0",
"instest09__PrimaryMemberIdentifier__c": "a5k6g000000T7REAA0",
"Id": "a4N6g0000013CP5EAM"
},
{
"attributes": {
"type": "instest09__GroupCensusMember__c",
"url": "/services/data/v48.0/sobjects/instest09__GroupCensusMember__c/a4N6g0000013CP6EAM"
},
"Name": "Primary 2",
"instest09__CensusId__c": "a4O6g000000AuJBEA0",
"instest09__FirstName__c": "Primary 2",
"instest09__LastName__c": "Primary 2",
"instest09__Birthdate__c": "2020-03-04",
"instest09__IsPrimaryMember__c": true,
"instest09__MemberType__c": null,
"instest09__NumberOfDependents__c": 0,
"instest09__Gender__c": "Male",
"instest09__MemberIdentifier__c": "a5k6g000000T7RJAA0",
"instest09__PrimaryMemberIdentifier__c": null,
"Id": "a4N6g0000013CP6EAM"
},
{
"attributes": {
"type": "instest09__GroupCensusMember__c",
"url": "/services/data/v48.0/sobjects/instest09__GroupCensusMember__c/a4N6g0000013CP7EAM"
},
"Name": "Dependent Spouse",
"instest09__CensusId__c": "a4O6g000000AuJBEA0",
"instest09__FirstName__c": "Spouse 1",
"instest09__LastName__c": "Spouse 1",
"instest09__Birthdate__c": "2020-03-12",
"instest09__IsPrimaryMember__c": true,
"instest09__IsSpouse__c": true,
"instest09__MemberType__c": null,
"instest09__NumberOfDependents__c": 0,
"instest09__Gender__c": "Female",
"instest09__MemberIdentifier__c": "a5k6g000000T7ROAA0",
"instest09__PrimaryMemberIdentifier__c": "a5k6g000000T7REAA0",
"Id": "a4N6g0000013CP7EAM"
}
],
"censusMemberCount": 4,
"census": {
"attributes": {
"type": "instest09__GroupCensus__c",
"url": "/services/data/v48.0/sobjects/instest09__GroupCensus__c/a4O6g000000AuJBEA0"
},
"Name": "Test Insured Census",
"instest09__EffectiveStartDate__c": "2020-03-26",
"instest09__EffectiveEndDate__c": "2020-03-26",
"instest09__CensusSource__c": "External",
"instest09__GroupId__c": "0016g00000Ir5LsAAJ",
"instest09__CensusType__c": "Group",
"Id": "a4O6g000000AuJBEA0"
},
"error": "OK"
}
