Normalize a party name and search matters/adverse parties for conflict hits before intake. The workbook becomes the system of record; Apps Script owns the joins and business rules so analysts are not pasting monthly formulas.
Entry point `runConflictCheck` reads typed columns with SpreadsheetApp batch APIs. SpreadsheetApp is the primary service; Manual describes how you usually invoke it after authorization.
Keep thresholds (grace days, bands, alert emails, API keys) in Config cells or Script Properties so the same .gs file promotes from sandbox to production without code edits.
This page is technical only: sheet layout, edge cases, runnable code, deploy steps, and FAQs for run a legal conflict check lookup. No consulting pitch—just the pattern you can paste and harden.
Need this built? Hire a Google Apps Script developer →
Sheet / project setup
| Tab | Columns | Notes |
|---|---|---|
| Matters | Id, Client, Adverse, Status | Matters |
| Parties | Name, Role, MatterId | Index |
| Conflicts | Hits | Output |
What this script does
runConflictCheck() normalize a party name and search matters/adverse parties for conflict hits before intake.
- Name normalization
- Matter + party search
- Hit sheet output
Prerequisites
Container-bound script on the workbook that contains the tabs in the setup table. Authorize SpreadsheetApp scopes on first run.
- V8 runtime
- Exact sheet names
- Script timezone = ops timezone
Walkthrough
Normalize query (lowercase, strip punctuation), substring-match Matters and Parties, write Conflicts hit list.
Paste the code, set Config/Properties, run runConflictCheck once, verify the output tab, then attach a Manual trigger.
Edge cases
Short queries (1–2 chars) over-match—enforce a minimum length in the prompt handler if needed.
Testing
Use a sandbox copy with 3–5 known rows. Compute expected outputs for run a legal conflict check lookup offline, run runConflictCheck, and diff the output tab including one intentional bad row.
Hardening
Add LockService around multi-sheet writes if triggers can overlap. Log run timestamps. Keep API keys and alert emails in PropertiesService—not in shared cells.
Variations
Fork ideas: filter to one business unit, change grain (daily→weekly), or POST a summary payload after runConflictCheck succeeds.
Operations notes
Assign an owner for the output tab, document regenerate steps, and treat `runConflictCheck` as source of truth over ad-hoc cell formulas.
Full code: runConflictCheck()
Run runConflictCheck when source tabs are current. Edit sheet names and Config/Properties first.
function normalizeName_(s){
return String(s||'').toLowerCase().replace(/[^a-z0-9 ]/g,'').replace(/\s+/g,' ').trim();
}
function runConflictCheck(){
const ui=SpreadsheetApp.getUi();
const q=normalizeName_(ui.prompt('Party name to check').getResponseText());
const ss=SpreadsheetApp.getActive();
const hits=[];
ss.getSheetByName('Matters').getDataRange().getValues().slice(1).forEach(r=>{
const client=normalizeName_(r[1]), adverse=normalizeName_(r[2]);
if(client.indexOf(q)>=0||adverse.indexOf(q)>=0||q.indexOf(client)>=0){
hits.push([r[0],r[1],r[2],r[3],'MATTER']);
}
});
ss.getSheetByName('Parties').getDataRange().getValues().slice(1).forEach(r=>{
if(normalizeName_(r[0]).indexOf(q)>=0) hits.push(['',r[0],r[1],r[2],'PARTY']);
});
const sh=ss.getSheetByName('Conflicts');
sh.clearContents();
sh.appendRow(['MatterId','NameA','NameB','Status','Source']);
if(hits.length) sh.getRange(2,1,hits.length+1,5).setValues(hits);
else sh.appendRow(['—','No hits','','','']);
}- Line 4: Entry point — bind triggers to runConflictCheck.
- Line 5: Interactive prompts — run from the sheet UI, not headless triggers.
- Line 9: Batch read; avoid per-cell getValue in loops.
- Line 21: Batch write output rows in one setValues call.
- Line 6: Rename sheet constants before production.
Deploy this example
- 01
Open Apps Script
In the bound spreadsheet: Extensions → Apps Script. For standalone projects, create one at script.google.com and link your Sheet by ID.
- 02
Paste and save
Add a .gs file, paste the code below, rename constants at the top (sheet names, column letters, API property keys), then save.
- 03
Authorize once
Run the main function from the editor. Accept OAuth scopes when prompted — triggers cannot run until authorization succeeds once.
- 04
Add the trigger
Triggers → Add trigger → choose the handler function and event (time-driven, on edit, or on form submit). Delete test triggers before production.
Before you run: run a legal conflict check lookup
- 1Setup tabs exist with headers matching runConflictCheck
- 2Dry-run on a copy workbook
- 3Timezone verified
- 4SpreadsheetApp authorization completed
- 5Output spot-checked against hand calc
- 6Manual trigger added only after validation
- 7Owners + alert recipients documented
Frequently asked questions
At minimum the tabs listed in the setup table for Run a Legal Conflict Check Lookup. Output tabs may be cleared each run—do not store source-of-truth data there.
Run from the Apps Script editor for dry runs. Production usually uses a Manual trigger after OAuth succeeds once.
Short queries (1–2 chars) over-match—enforce a minimum length in the prompt handler if needed.
Per-cell calls burn quota and wall time. One read + one write keeps this pattern under the 6-minute execution cap longer.
PropertiesService (Script Properties) for API keys and alert inboxes. Config sheet is fine for non-secret thresholds.
Simple ratios maybe; run a legal conflict check lookup needs joins, branching, or side effects (email/Docs/API) that Apps Script handles cleanly.
Keep the .gs in clasp/git. Avoid divergent copies of formulas on the output tab—regenerate from the script.