Area: Product Issues
Sub-Area: Compliance Forms / Notifications
Applies to: Cloud
Issue
You want DataHub to alert a person or group when a compliance form is completed on an asset. You can't find any setting for this in the form editor, in your notification settings, or in the API.
You Might Be Asking
- Where do I configure a notification for when a compliance form is completed?
- Can DataHub alert a team when all assignees finish a compliance form on a dataset?
- How do I detect newly completed compliance forms programmatically?
- How do I find the URN of my compliance form?
Cause
DataHub Cloud has one compliance form notification trigger: it notifies assignees when a form is published. In the form editor this is the Send notifications to assignees when this form is published checkbox in the Add Recipients step. As of DataHub Cloud v2.4.4 there is no trigger for form completion, in the UI or in the API.
DataHub does record completion on each asset. A form counts as completed on an asset when all of its required questions have answers. DataHub indexes completed and incomplete forms per asset, so you can search for them with GraphQL and build your own alert.
Solution
1. Know what DataHub sends today
Manage compliance forms under Govern > Compliance Forms. When you publish a form with Send notifications to assignees when this form is published checked, assignees get a task in their Task Center, plus a notification on the channels they turned on under Settings > My Notifications (the Compliance Forms group). See Create a Compliance Form, Step 4 and Step 5.
If you don't see the notification checkbox in the form editor, or the Compliance Forms group under Settings > My Notifications, form notifications are not turned on for your instance. Contact DataHub Support to turn them on.
2. Find your form URN
There is no listForms query. Search for entities of type FORM instead:
{
searchAcrossEntities(input: {
types: [FORM],
query: "*",
start: 0,
count: 50
}) {
total
searchResults {
entity {
urn
... on Form {
info {
name
}
}
}
}
}
}
See the DataHub GraphQL API overview for how to send GraphQL requests.
3. Query the assets that completed the form
Filter searchAcrossEntities on the completedForms field. Replace <your-form-urn> with the URN from step 2.
{
searchAcrossEntities(input: {
query: "*",
start: 0,
count: 100,
orFilters: [
{
and: [
{
field: "completedForms",
values: ["<your-form-urn>"]
}
]
}
]
}) {
total
searchResults {
entity {
urn
}
}
}
}
4. Query the assets that still have the form open
Use the same query with the field incompleteForms:
{
searchAcrossEntities(input: {
query: "*",
start: 0,
count: 100,
orFilters: [
{
and: [
{
field: "incompleteForms",
values: ["<your-form-urn>"]
}
]
}
]
}) {
total
searchResults {
entity {
urn
}
}
}
}
5. Run the query on a schedule and compare results
Run the completedForms query on a schedule, for example from a cron job or an Airflow DAG. Save the URNs from each run. A URN in the current run that was not in the previous run is a new completion. Send those URNs to your own alerting tool (email, Slack, PagerDuty, and so on).
The search results are paged. If total is larger than count, raise start by count and call again until you have all results.
A minimal pattern:
# Pseudocode: adapt to your language and scheduler
previous_urns = load_from_store("completed_urns_previous_run")
current_urns = set(run_graphql_query(completedForms_query))
newly_completed = current_urns - previous_urns
if newly_completed:
send_alert(
recipients=["team-group@example.com"],
message=f"These assets completed the compliance form: {newly_completed}"
)
save_to_store("completed_urns_previous_run", current_urns)