{ "kind": "open-flow-workflow", "version": 1, "name": "Create, Update and Read a FileMaker Record", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_02b4ce7a94831fd0": { "name": "Enter the contact and database", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "server" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "database" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "layout" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "firstName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "lastName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "country" } ] }, "n_14e5907d798b2f07": { "inputs": { "server": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "server" } ] }, "database": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "database" } ] }, "layout": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "layout" } ] }, "firstName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "firstName" } ] }, "lastName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "lastName" } ] }, "country": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_02b4ce7a94831fd0", "output": "country" } ] } }, "name": "Prepare the record", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "server" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "database" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "layout" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "firstName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "lastName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "country" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "country" } ], "name": "Prepare the record", "moduleId": "n_3efd0a9032bc37eb", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_921f421485e0a1a4": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_14e5907d798b2f07", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_14e5907d798b2f07", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create the record", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Create the record", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_b33531fe9c7f0e06": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_921f421485e0a1a4", "output": "body" } ] }, "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_14e5907d798b2f07", "output": "url" } ] }, "country": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_14e5907d798b2f07", "output": "country" } ] } }, "name": "Prepare the country update", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "country" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare the country update", "moduleId": "n_b078c35e3ddfc229", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3cdbb55da52a4324": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b33531fe9c7f0e06", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b33531fe9c7f0e06", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Update the country", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Update the country", "executor": { "method": "PATCH", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_672e700cad2b1ac8": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3cdbb55da52a4324", "output": "body" } ] }, "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b33531fe9c7f0e06", "output": "url" } ] } }, "name": "Confirm the update", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "name": "Confirm the update", "moduleId": "n_3e05155b4fc7237f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_613bb98ffe259818": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_672e700cad2b1ac8", "output": "url" } ] }, "auth.token": { "kind": "unset" } }, "name": "Read the record", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Read the record", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_038ef83e2e08c9a0": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_613bb98ffe259818", "output": "body" } ] } }, "name": "Check the returned record", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "record" } ], "name": "Check the returned record", "moduleId": "n_b98f4a062bfc9f1e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_733eac2f717981da": { "name": "Return the record", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "record" } ], "outputMappings": { "record": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_038ef83e2e08c9a0", "output": "record" } ] } } } }, "edges": [ { "source": "n_02b4ce7a94831fd0", "target": "n_14e5907d798b2f07" }, { "source": "n_14e5907d798b2f07", "target": "n_921f421485e0a1a4" }, { "source": "n_921f421485e0a1a4", "target": "n_b33531fe9c7f0e06" }, { "source": "n_b33531fe9c7f0e06", "target": "n_3cdbb55da52a4324" }, { "source": "n_3cdbb55da52a4324", "target": "n_672e700cad2b1ac8" }, { "source": "n_672e700cad2b1ac8", "target": "n_613bb98ffe259818" }, { "source": "n_613bb98ffe259818", "target": "n_038ef83e2e08c9a0" }, { "source": "n_038ef83e2e08c9a0", "target": "n_733eac2f717981da" } ] } }, "modules": { "n_3efd0a9032bc37eb": { "name": "Prepare the record", "imports": [], "source": "export default function config({server,database,layout,firstName,lastName,country}){for(const x of [server,database,layout,firstName,lastName,country])if(typeof x!=='string'||!x.trim())throw Error('All settings are required');if(!/^https:\\/\\/[^/\\s]+$/.test(server))throw Error('Use the HTTPS FileMaker server origin');const url=server+'/fmi/data/vLatest/databases/'+encodeURIComponent(database)+'/layouts/'+encodeURIComponent(layout)+'/records';return{url,body:{fieldData:{first_name:firstName,last_name:lastName}},country}}\n" }, "n_b078c35e3ddfc229": { "name": "Prepare the country update", "imports": [], "source": "export default function created({body,url,country}){if(!body||!Array.isArray(body.messages)||body.messages.some(m=>m.code!=='0')||!body.response||!/^\\d+$/.test(String(body.response.recordId))||!/^\\d+$/.test(String(body.response.modId)))throw Error('FileMaker did not confirm record creation');return{url:url+'/'+body.response.recordId,body:{fieldData:{address_country:country},modId:body.response.modId}}}\n" }, "n_3e05155b4fc7237f": { "name": "Confirm the update", "imports": [], "source": "export default function confirm({body,url}){if(!body||!Array.isArray(body.messages)||body.messages.some(m=>m.code!=='0')||!body.response||!/^\\d+$/.test(String(body.response.modId)))throw Error('FileMaker did not confirm update');return{url}}\n" }, "n_b98f4a062bfc9f1e": { "name": "Check the returned record", "imports": [], "source": "export default function result({body}){if(!body||!Array.isArray(body.messages)||body.messages.some(m=>m.code!=='0')||!Array.isArray(body.response?.data)||body.response.data.length!==1)throw Error('FileMaker did not return one record');return{record:body.response.data[0]}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }