{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update a Salesforce Lead with a Note", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_9698345e95c8c3fd": { "name": "Enter lead details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "lastName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "noteTitle" } ] }, "n_a20b3abdb2d18510": { "inputs": { "company": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9698345e95c8c3fd", "output": "company" } ] }, "lastName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9698345e95c8c3fd", "output": "lastName" } ] } }, "name": "Create lead", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "company" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "lastName" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" } ], "name": "Create lead", "moduleId": "n_83b56c422ec40b6d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "salesforce.create_record" } ] } ] } }, "n_ef08b5e9a486165b": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a20b3abdb2d18510", "output": "id" } ] }, "city": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9698345e95c8c3fd", "output": "city" } ] } }, "name": "Update lead city", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "city" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" } ], "name": "Update lead city", "moduleId": "n_a88bc7d0e8d7a3b3", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "salesforce.update_record" } ] } ] } }, "n_82ae8c45c277f5b5": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ef08b5e9a486165b", "output": "id" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9698345e95c8c3fd", "output": "noteTitle" } ] } }, "name": "Add lead note", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "noteId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "leadId" } ], "name": "Add lead note", "moduleId": "n_c6a885ebc93a8762", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "salesforce.create_record" } ] } ] } }, "n_46b5e85d8e8d4bb3": { "name": "Lead and note IDs", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "leadId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "noteId" } ], "outputMappings": { "leadId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_82ae8c45c277f5b5", "output": "leadId" } ] }, "noteId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_82ae8c45c277f5b5", "output": "noteId" } ] } } } }, "edges": [ { "source": "n_9698345e95c8c3fd", "target": "n_a20b3abdb2d18510" }, { "source": "n_a20b3abdb2d18510", "target": "n_ef08b5e9a486165b" }, { "source": "n_ef08b5e9a486165b", "target": "n_82ae8c45c277f5b5" }, { "source": "n_82ae8c45c277f5b5", "target": "n_46b5e85d8e8d4bb3" } ] } }, "modules": { "n_83b56c422ec40b6d": { "name": "Create lead", "imports": [], "source": "export default async function({company,lastName},ctx){if(!company.trim()||!lastName.trim())throw Error('Enter a company and last name');const r=await ctx.actions.call('salesforce.create_record',{objectName:'Lead',fields:{Company:company,LastName:lastName}});if(r?.success!==true||typeof r.id!=='string'||!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(r.id))throw Error('Lead creation not confirmed');return{id:r.id}}\n" }, "n_a88bc7d0e8d7a3b3": { "name": "Update lead city", "imports": [], "source": "export default async function({id,city},ctx){if(!city.trim())throw Error('Enter a city');const r=await ctx.actions.call('salesforce.update_record',{objectName:'Lead',recordId:id,fields:{City:city}});if(r?.success!==true)throw Error('Lead update not confirmed');return{id}}\n" }, "n_c6a885ebc93a8762": { "name": "Add lead note", "imports": [], "source": "export default async function({id,title},ctx){if(!title.trim())throw Error('Enter a note title');const r=await ctx.actions.call('salesforce.create_record',{objectName:'Note',fields:{ParentId:id,Title:title}});if(r?.success!==true||typeof r.id!=='string'||!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(r.id))throw Error('Note creation not confirmed');return{noteId:r.id,leadId:id}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }