createRefContactsFromCapContactsAndLink
This function can be used as the basis for maintaining a contact-centric database within Civic Platform.
Version
1.6
Parameters
Parameter | Type | Description |
---|---|---|
pCapId | CapIDModel | Record to work with. |
contactTypeArray | array | The contact types to process, or null for all. This parameter is ignored if the REF_CONTACT_ENFORCE_TYPE_FLAG_WITH_EMSE standard choice is configured. See description for more detail. |
ignoreAttributeArray | array | An array of attributes to ignore when creating a REF contact, or null. |
replaceCapContact | boolean | Not implemented. |
overwriteRefContact | boolean | If true, refreshes the linked ref contact with record contact data. |
refContactExists | function | Function used to determine if the reference contact exists. |
Example
iArr = new Array();
iArr.push(“Partner Percent”)
createRefContactsFromCapContactsAndLink(capId,null,iArr,false,true,
comparePeopleGeneric);
In this example, when this code is executed, the function loops through all contacts on the current record. If the contact was hand-entered (not selected and validated from reference contacts) the reference contacts searches for a match using the comparePeopleGeneric function. If a match is found, the record contact links to the reference contact. Also, the reference contact refreshes with data from the cap contact. All attributes refresh except for the “Partner Percent” field.
Version 2.0 Update: This function now checks for the presence of a standard choice “REF_CONTACT_CREATION_RULES”. See screenshot below for configuration.
This setting determines whether to create the reference contact, as well as the contact type with which to create the reference contact. If this setting is configured, the function ignores the contactTypeArray parameter. The “Default” in this standard choice determines the default action of all contact types. Other types can be configured separately. Each contact type can be set to “I” (create ref as individual), “O” (create ref as organization), “F” (follow the indiv/org flag on the cap contact), “D” (Do not create a ref contact), or “U” (create ref using the transactional contact type”).