← back to Filemaker Mcp
sync: refresh existing client's contact info from the order before invoicing (update client first, then invoice)
c4dc44015021e6be9f7093831448b74520490157 · 2026-06-29 12:23:21 -0700 · Steve
Files touched
Diff
commit c4dc44015021e6be9f7093831448b74520490157
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Jun 29 12:23:21 2026 -0700
sync: refresh existing client's contact info from the order before invoicing (update client first, then invoice)
---
lib/sync-core.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/sync-core.js b/lib/sync-core.js
index dca414c..8f6889a 100644
--- a/lib/sync-core.js
+++ b/lib/sync-core.js
@@ -72,8 +72,16 @@ export async function syncOrder(order, { commit = true } = {}) {
let clientAction, accountNumber;
const dupes = await findDuplicates(mapped);
if (dupes.length) {
- clientAction = 'existing';
accountNumber = dupes[0].acct;
+ clientAction = 'existing';
+ // refresh the existing client's contact info from this order BEFORE invoicing
+ if (commit && dupes[0].recordId) {
+ const refresh = {};
+ for (const k of ['Address', 'City', 'State', 'Zip', 'Phone', 'Email address']) {
+ if (mapped.fields[k]) refresh[k] = mapped.fields[k];
+ }
+ try { await fm.updateRecord('Clients', LAYOUT, dupes[0].recordId, refresh, { dryRun: false }); clientAction = 'updated'; } catch {}
+ }
} else if (commit) {
const res = await fm.createRecord('Clients', LAYOUT, mapped.fields, { dryRun: false });
try { accountNumber = (await fm.getRecord('Clients', LAYOUT, res.recordId))?.fieldData?.['Account Number']; } catch {}
← e2e050f sync: every new order now auto-creates client + full invoice
·
back to Filemaker Mcp
·
auto-save: 2026-06-29T12:49:09 (2 files) — lib/invoice.js sr 1894d57 →