User and group fields
VI stores user-chooser and group-chooser fields as JSON-encoded arrays of
{"id": "...", "type": "user" | "group"} objects. The SDK gives you typed UserRef
and GroupRef wrappers. Pass them as field values and the SDK writes the wire format.
import sasvi
from sasvi import GroupRef, UserRef
client = sasvi.SVIClient.from_env()
doc = client.documents.get(entity_type_name="<your-entity-type>", document_id="<id>")
doc.update_fields(
assigned_user_id=UserRef(id="analyst.alpha"),
notified_groups=[GroupRef(id="fraud-ops"), GroupRef(id="case-management")],
)
The first field is a single-user chooser, the second a multi-select group chooser. Pass a list when the entity-type metadata says the field allows multiple selections, and a single ref otherwise.
The SDK writes a UserRef, a GroupRef or a list of them as the chooser string even when the
tenant reports the field as STRING, which is how manifest-provisioned chooser fields read back.
The other forms below need the field to report USER_GROUP.
When you only have an id and a kind
doc.update_fields(
assigned_user_id=("analyst.alpha", "user"),
review_group_id={"id": "fraud-ops", "type": "group"},
)
Plain (id, kind) tuples and {"id": ..., "type": ...} dicts work too. The SDK
normalizes them to the wire format.
Clear the chooser
Pass None:
doc.update_fields(assigned_user_id=None)
Round-trip an existing value
Reading a chooser value back as a list of UserRef / GroupRef is not built in, but
it is three lines:
import json
raw = doc.get_field("assigned_user_id")
if isinstance(raw, str) and raw.startswith("["):
refs = json.loads(raw)
user_ids = [item["id"] for item in refs if item.get("type") == "user"]
Async
await doc.update_fields_async(
assigned_user_id=UserRef(id="analyst.alpha"),
)
Go further
- Documents guide. How
update_fieldscoerces field types. - Discover your environment. Find which fields are
user or group choosers through
entity_type.field(...).logical_data_type.