TLDR: When a matter transitions to Active, fire your full file ecosystem — Drive folders, Gmail label, Xero project — in one burst from inside the app. But resolve every dependency before you call downstream services.
the setup
I'm building a custom practice management system for my business partner's small law firm.
Every new lead lands in the system as PNC — Pending New Client.
Our intake coordinator fills the Fillout intake form (our internal intake tool), the matter gets created, an automated conflict check runs. my business partner reviews it. If it's clear, she flips the status to Active.
That flip is the moment everything should happen.
what fires when it goes active
Three things, in parallel:
- Google Drive: Build a folder hierarchy under
Open Matters/{Matter Number}/on the firm's Shared Drive - Gmail: Create a label under
Open Matters/{Matter Number} - Xero (accounting + time-tracking): Find or create a Contact → create a Project → add a Task at a default hourly rate
The original plan was Make.com (a no-code automation platform) for all of this. But somewhere in an early call with my business partner I said it out loud:
"The beautiful thing about the custom solution is you eliminate the need for Make. In the application itself, we have an environment to run our own scripts — our own API calls securely, not on Make's server. We connect directly to Google Drive. We connect directly to Xero."
So that's what we built. State changes to Active → in-app script fires → direct API calls. No external platform, no webhook chain to babysit.
the folder template question
Not all matters are the same.
A normal litigation matter needs one Drive structure. A Trademark matter needs a different one — different workflow, different sub-folders entirely.
So the script reads the matter category first, picks a template (Normal or Trademark), then builds the tree.
The transition is the decision point. The matter already knows what it is — you just have to ask before you act.
what broke
First live test: a nutrition nonprofit client goes Active.
I watch the logs. Error.
"It aired out because it was missing ID. Oh, because there was no client associated with that matter."
Xero can't create a Project without a Contact ID. Our script was calling create Project before confirming the Xero Contact existed.
Template selection? Correct. Drive folder logic? Fine. The Xero step just… assumed a contact was there.
It wasn't.
the fix
Find or create the Xero contact before creating the project.
Search for a matching contact. If it exists — use it. If not — create it first, then create the Project and Task underneath it.
One extra step. Completely reliable after that.
"If you want to add a client and then switch it back from PNC to Active, that should re-trigger it."
It did. Everything fired clean.
why this matters to me
State transitions are the right place to hang automations. The moment a status changes is when intent is declared — and that moment should kick off everything downstream in one coherent burst.
But the pattern that'll stick is simpler: resolve your dependencies before you call downstream services. Don't assume the Xero contact exists. Don't assume the Drive folder doesn't. Find-or-create is a pattern you'll reach for constantly — and the first time you skip it, the whole activation sequence fires straight into a wall.