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
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
create(data: FieldCreate) -> FieldMetadata
¶
Create a custom field.
Source code in affinity/services/v1_only.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
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
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
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
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
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
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
list(*, list_id: ListId | None = None, entity_type: EntityType | None = None) -> list[FieldMetadata]
¶
Get fields (V1 API).
For list/person/company field metadata, prefer the V2 read endpoints on the
corresponding services when available (e.g., client.lists.get_fields(...)).
Source code in affinity/services/v1_only.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |