Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .claude/skills/dataverse-sdk-use/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,63 @@ for table in tables:
print(table)
```

#### Get Extended Table Metadata
```python
# Get table with column metadata
info = client.tables.get("account", include_columns=True)
for col in info["columns"]:
print(f"{col.logical_name} ({col.attribute_type})")

# Get table with relationship metadata
info = client.tables.get("account", include_relationships=True)

# Get specific entity properties
info = client.tables.get("account", select=["DisplayName", "Description"])
```

#### List Columns
```python
from PowerPlatform.Dataverse.models.metadata import ColumnMetadata

columns = client.tables.get_columns("account")
for col in columns:
print(f"{col.schema_name}: {col.attribute_type} (required: {col.required_level})")

# Filter to specific column types (OData syntax, fully-qualified enum)
picklists = client.tables.get_columns(
"account",
filter="AttributeType eq Microsoft.Dynamics.CRM.AttributeTypeCode'Picklist'",
)
```

#### Get Single Column
```python
col = client.tables.get_column("account", "emailaddress1")
if col:
print(f"Type: {col.attribute_type}, Required: {col.required_level}")
```

#### Get Column Options (Picklist/Choice Values)
```python
from PowerPlatform.Dataverse.models.metadata import OptionSetInfo

options = client.tables.get_column_options("account", "accountcategorycode")
if options:
for opt in options.options:
print(f" Value={opt.value}, Label={opt.label}")
```

#### List Table Relationships
```python
# All relationships
rels = client.tables.list_relationships("account")

# Specific type: "one_to_many" / "1:N", "many_to_one" / "N:1", "many_to_many" / "N:N"
rels = client.tables.list_relationships("account", relationship_type="one_to_many")
for rel in rels:
print(f"{rel['SchemaName']}: {rel.get('ReferencingEntity')}")
```

#### Delete Tables
```python
client.tables.delete("new_Product")
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,40 @@ client.tables.remove_columns("new_Product", ["new_Category"])
client.tables.delete("new_Product")
```

```python
# Get extended table metadata with columns
info = client.tables.get("account", include_columns=True)
for col in info["columns"]:
print(f"{col.logical_name} ({col.attribute_type})")

# Get extended table metadata with relationships
info = client.tables.get("account", include_relationships=True)
for rel in info.get("one_to_many_relationships", []):
print(rel["SchemaName"])

# Get specific entity properties
info = client.tables.get("account", select=["DisplayName", "Description"])

# List all columns of a table
columns = client.tables.get_columns("account")
for col in columns:
print(f"{col.schema_name}: {col.attribute_type} (required: {col.required_level})")

# Get a specific column's metadata
col = client.tables.get_column("account", "emailaddress1")
if col:
print(f"Type: {col.attribute_type}, Required: {col.required_level}")

# Get picklist/choice column options
options = client.tables.get_column_options("account", "accountcategorycode")
if options:
for opt in options.options:
print(f" {opt.value}: {opt.label}")

# List relationships for a table
rels = client.tables.list_relationships("account", relationship_type="one_to_many")
```

> **Important**: All custom column names must include the customization prefix value (e.g., `"new_"`).
> This ensures explicit, predictable naming and aligns with Dataverse metadata requirements.

Expand Down
29 changes: 29 additions & 0 deletions src/PowerPlatform/Dataverse/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,32 @@

CASCADE_BEHAVIOR_RESTRICT = "Restrict"
"""Prevent the referenced table record from being deleted when referencing table records exist."""

# AttributeMetadata derived type OData identifiers
# Used when casting Attributes collection to a specific derived type in Web API URLs
ODATA_TYPE_PICKLIST_ATTRIBUTE = "Microsoft.Dynamics.CRM.PicklistAttributeMetadata"
ODATA_TYPE_BOOLEAN_ATTRIBUTE = "Microsoft.Dynamics.CRM.BooleanAttributeMetadata"
ODATA_TYPE_MULTISELECT_PICKLIST_ATTRIBUTE = "Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata"
ODATA_TYPE_STATUS_ATTRIBUTE = "Microsoft.Dynamics.CRM.StatusAttributeMetadata"
ODATA_TYPE_STATE_ATTRIBUTE = "Microsoft.Dynamics.CRM.StateAttributeMetadata"
ODATA_TYPE_STRING_ATTRIBUTE = "Microsoft.Dynamics.CRM.StringAttributeMetadata"
ODATA_TYPE_INTEGER_ATTRIBUTE = "Microsoft.Dynamics.CRM.IntegerAttributeMetadata"
ODATA_TYPE_DECIMAL_ATTRIBUTE = "Microsoft.Dynamics.CRM.DecimalAttributeMetadata"
ODATA_TYPE_DOUBLE_ATTRIBUTE = "Microsoft.Dynamics.CRM.DoubleAttributeMetadata"
ODATA_TYPE_MONEY_ATTRIBUTE = "Microsoft.Dynamics.CRM.MoneyAttributeMetadata"
ODATA_TYPE_DATETIME_ATTRIBUTE = "Microsoft.Dynamics.CRM.DateTimeAttributeMetadata"
ODATA_TYPE_MEMO_ATTRIBUTE = "Microsoft.Dynamics.CRM.MemoAttributeMetadata"
ODATA_TYPE_FILE_ATTRIBUTE = "Microsoft.Dynamics.CRM.FileAttributeMetadata"

# Attribute type code values returned in the AttributeType property of attribute metadata
ATTRIBUTE_TYPE_PICKLIST = "Picklist"
ATTRIBUTE_TYPE_BOOLEAN = "Boolean"
ATTRIBUTE_TYPE_STRING = "String"
ATTRIBUTE_TYPE_INTEGER = "Integer"
ATTRIBUTE_TYPE_DECIMAL = "Decimal"
ATTRIBUTE_TYPE_DOUBLE = "Double"
ATTRIBUTE_TYPE_MONEY = "Money"
ATTRIBUTE_TYPE_DATETIME = "DateTime"
ATTRIBUTE_TYPE_MEMO = "Memo"
ATTRIBUTE_TYPE_LOOKUP = "Lookup"
ATTRIBUTE_TYPE_UNIQUEIDENTIFIER = "Uniqueidentifier"
Loading