Fields (V1)¶
Service for managing custom fields.
Use V2 /fields endpoints for reading field metadata. Use V1 for creating/deleting fields.
Source code in affinity/services/v1_only.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
create(data: FieldCreate) -> FieldMetadata
¶
Create a custom field.
Source code in affinity/services/v1_only.py
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | |
delete(field_id: FieldId) -> bool
¶
Delete a custom field (V1 API).
Note: V1 deletes require numeric field IDs. The SDK accepts V2-style
field-<digits> IDs and converts them; enriched/relationship-intelligence
IDs are not supported.
Source code in affinity/services/v1_only.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
exists(field_id: AnyFieldId) -> bool
¶
Check if a field exists.
Useful for validation before setting field values.
Note: This fetches all fields and checks locally. If your code calls exists() frequently in a loop, consider caching the result of fields.list() yourself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_id
|
AnyFieldId
|
The field ID to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the field exists, False otherwise |
Example
if client.fields.exists(FieldId("field-123")): client.field_values.create(...)
Source code in affinity/services/v1_only.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 | |
get_by_name(name: str) -> FieldMetadata | None
¶
Find a field by its display name.
Uses case-insensitive matching (casefold for i18n support).
Note: This fetches all fields and searches locally. If your code calls get_by_name() frequently in a loop, consider caching the result of fields.list() yourself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The field display name to search for |
required |
Returns:
| Type | Description |
|---|---|
FieldMetadata | None
|
FieldMetadata if found, None otherwise |
Example
field = client.fields.get_by_name("Primary Email Status") if field: fv = client.field_values.get_for_entity(field.id, person_id=pid)
Source code in affinity/services/v1_only.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
list(*, list_id: ListId | None = None, entity_type: EntityType | None = None) -> list[FieldMetadata]
¶
Get field metadata.
Results are cached for 5 minutes when caching is enabled on the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list_id
|
ListId | None
|
Filter to fields for a specific list |
None
|
entity_type
|
EntityType | None
|
Filter to fields for a specific entity type |
None
|
Returns:
| Type | Description |
|---|---|
list[FieldMetadata]
|
List of field metadata |
Source code in affinity/services/v1_only.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | |