AffinityScoreDefinition

Represents the affinity information used in calculations to analyze and categorize contacts for marketing purposes.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Parent Type

This type extends the Metadata metadata type and inherits its fullName field.

File Suffix and Directory Location

AffinityScoreDefinition components have the suffix .affinityScoreDefinition and are stored in the affinityScoreDefinitions folder.

Version

AffinityScoreDefinition components are available in API version 66.0 and later.

Special Access Rules

This metadata type is available only if the Fundraising Access license is enabled for the org and the Fundraising admin permission is assigned to users.

Fields

Field Name Field Type Description
affinityScoreDefinitionDesc string Description of the affinity score definition.
affinityScoreDefinitionName string Name of the affinity score definition.
affinityScoreType AffinityScoreType (enumeration of type string) Type of the affinity score that's defined. Valid values are CAP—Capacity, Ability, Propensity (CAP), or RFM—Recency, Frequency, Monetary (RFM). The default value is RFM.
masterLabel string Label for this affinity score definition value. This display value is the internal label that doesn't get translated.
numberOfMonths int Number of months to analyze the records for calculating the affinity score.
numberOfRanges int Required. Number of ranges to use in the calculation, ranging from 0 to 9. Provide the corresponding range list values in the scoreRangeList field.
scoreRangeList string Required. Ranges that are referenced in the affinity score calculation. This field is used with scoreRangeList. For example, to calculate RFM with numberOfRanges value as 3, provide the values for the scoreRangeList field.
sourceFieldApiNameList string Required. API names of the source fields that are referenced in the score calculation.
sourceObjectApiNameList string API names of the source objects that are referenced in the score calculation.
targetFieldApiNameList string Required. API names of the target fields where the calculated scores are added.
targetObjectApiName string API name of the target object where the calculated scores are added.

Example scoreRangeList format:

1{
2    "R ranges":"0-30, 31-100, 100+",
3    "F ranges":"0-10, 11-100, 100+",
4    "M ranges":"0-1000, 1001-5000, 5000+"
5}

Declarative Metadata Sample Definition

This example shows a sample of an AffinityScoreDefinition component.

1<?xml version="1.0" encoding="UTF-8"?>
2<AffinityScoreDefinition
3	xmlns="http://soap.sforce.com/2006/04/metadata">
4	<affinityScoreDefinitionDesc>RFM Affinity Score</affinityScoreDefinitionDesc>
5	<affinityScoreDefinitionName>AffinityScoreDefinition_RFM</affinityScoreDefinitionName>
6	<affinityScoreType>RFM</affinityScoreType>
7	<masterLabel>MasterLabel</masterLabel>
8	<numberOfMonths>12</numberOfMonths>
9	<numberOfRanges>3</numberOfRanges>
10	<scoreRangeList>
11        [
12          {
13            "name": "R Ranges",
14            "direction": "ascending",
15            "ranges": [30,90,180]
16          },
17          {
18            "name": "F Ranges",
19            "direction": "descending",
20            "ranges": [10,15,100]
21          },
22          {
23            "name": "M Ranges",
24            "direction": "descending",
25            "ranges": [500,1000,5000]
26          }
27     ]
28      </scoreRangeList>
29	<sourceFieldApiNameList>
30        [
31          {
32            "name": "R Source",
33            "values": 
34                [
35                  {
36                    "fieldName": "DonorGiftSummary.DaysSinceLastGift",
37                    "fieldWeight": 1
38                  }
39                ]
40          },
41          {
42            "name": "F Source",
43            "values": 
44                [
45                  {
46                    "fieldName": "DonorGiftSummary.GiftCount",
47                    "fieldWeight": 1
48                  }
49                ]
50          },
51          {
52            "name": "M Source",
53            "values": 
54                [
55                  {
56                    "fieldName": "DonorGiftSummary.TotalGiftsCount",
57                    "fieldWeight": 1
58                  }
59                ]
60          }
61        ]
62      </sourceFieldApiNameList>
63	<targetFieldApiNameList>
64        [
65          {
66            "name": "R Target",
67            "values": 
68                [
69                  {
70                    "fieldName": "DonorGiftSummary.RecencyScore",
71                    "fieldWeight": 1
72                  }
73                ]
74          },
75          {
76            "name": "F Target",
77            "values": 
78                [
79                  {
80                    "fieldName": "DonorGiftSummary.FrequencyScore",
81                    "fieldWeight": 1
82                  }
83                ]
84          },
85          {
86            "name": "M Target",
87            "values": 
88                [
89                  {
90                    "fieldName": "DonorGiftSummary.MonetaryScore",
91                    "fieldWeight": 1
92                  }
93                ]
94          }
95        ]
96      </targetFieldApiNameList>
97</AffinityScoreDefinition>

This example shows a sample of the package.xml file that references the previous definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>*</members>
5        <name>AffinityScoreDefinition</name>
6    </types>
7    <version>66.0</version>
8</Package>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.