Nick Ashcroft 2/14/2020 5:52:24 AM
I have a 1-many relationship between 2 tables - document and document_relations. When a document (parent) is deleted, I want to delete all (child) document relations.
I dont know your use-case, but hopefully this can help get you started.
In the 'document' table I have a summary column which is a concentation of the id from 'document_relation' table named 'doc_relation_ids'
I have a 'formula url' column in the 'document' table called 'doc_relation_ids_delete' with the following formula:
"https://www.teamdesk.net/secure/api/v2/nnnnn/Document%20Relations/delete.json?key=" & Replace([doc_relation_ids],",","&key=")
(where nnnn is your database id)
This is replacing the comma separated list of id's inserting the term 'key=' between each value so multiple ids are deleted in one API call.
I added an 'on delete' trigger on the documents table which calls a 'call url' action named 'Delete Document Relations' with the following properties
- 'basic access' for authentication using some teamdesk credentials.
- method= 'get'
- url <%=[doc_relation_ids_delete]%>
so this calls the url as defined in the formula url column when a document is deleted.
Hope that helps !