{ "meta": { "instanceId": "3da9aa1165fccd6e57ad278dd59febaa1dfaafc31e0e52a95d11801200f09024", "templateCredsSetupCompleted": true }, "nodes": [ { "id": "c983fae5-a779-4a56-ace0-304aaefe0433", "name": "Append Material Request", "type": "n8n-nodes-base.googleSheets", "position": [ 6780, 3240 ], "parameters": { "columns": { "value": {}, "schema": [ { "id": "Timestamp", "type": "string", "display": true, "required": false, "displayName": "Timestamp", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Product ID", "type": "string", "display": true, "required": false, "displayName": "Product ID", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Quantity Requested", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Quantity Requested", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Measurement Unit", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Measurement Unit", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Requested By", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Requested By", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Issue Date", "type": "string", "display": true, "required": false, "displayName": "Issue Date", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Description", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Description", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Submission ID", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Submission ID", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Status", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Status", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Approval Link", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Approval Link", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Request Date", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Request Date", "defaultMatch": false, "canBeUsedToMatch": true } ], "mappingMode": "autoMapInputData", "matchingColumns": [], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {}, "operation": "append", "sheetName": { "__rl": true, "mode": "list", "value": 328307238, "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1q0S6AVK7uxZG8sUQkpcZr01KToHPjOZ0gG3zKHLR6lw/edit#gid=328307238", "cachedResultName": "Materials Issued" }, "documentId": { "__rl": true, "mode": "list", "value": "1q0S6AVK7uxZG8sUQkpcZr01KToHPjOZ0gG3zKHLR6lw", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1q0S6AVK7uxZG8sUQkpcZr01KToHPjOZ0gG3zKHLR6lw/edit?usp=drivesdk", "cachedResultName": "Plumbee Raw Material Delivery (Responses)" } }, "typeVersion": 4.5 }, { "id": "25d745c1-8167-4c55-9f88-461f94843286", "name": "Get Approvals", "type": "n8n-nodes-base.webhook", "position": [ 5900, 4060 ], "webhookId": "33876465-33a7-4cc1-bbb5-bc8c630edd9f", "parameters": { "path": "/approve-issue", "options": {} }, "typeVersion": 2 }, { "id": "c4d96a9c-b70b-4e40-bf9d-5e8f9426ee22", "name": "Standardize Data", "type": "n8n-nodes-base.set", "position": [ 6120, 3400 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "77dc2acf-9657-4013-9675-99311d299abe", "name": "Timestamp", "type": "string", "value": "={{ $json[\"Timestamp\"] || new Date().toISOString() }}" }, { "id": "a5706f57-d7ba-4ffa-a8c6-030bdb2e3d55", "name": "Product ID", "type": "string", "value": "={{ $json.body['Product ID'] }}" }, { "id": "53e04ca2-88cb-49a6-b878-4d7abde8806d", "name": "Quantity Requested", "type": "number", "value": "={{ $json.body['Quantity Requested'] }}" }, { "id": "9612c7a7-1f76-4168-9c89-d89421cc7c5a", "name": "Requested By", "type": "string", "value": "={{ $json.body['Requested By'] }}" }, { "id": "4b0f98cc-3e9f-42a4-81e7-c4c8c0a904eb", "name": "Description", "type": "string", "value": "={{ $json.body.Description }}" }, { "id": "a6a134ac-280c-4ef2-bbd6-e121376f9bbf", "name": "Submission ID", "type": "string", "value": "={{ $json.body['Submission ID'] }}" }, { "id": "e3a62912-773f-43f2-bf35-5b5e757c345d", "name": "Approval Link", "type": "string", "value": "=https://test.app.n8n.cloud/webhook/approve-issue?submissionId={{ $json.body['Submission ID'] }}\n\n" }, { "id": "22fb6d08-5f7e-42dc-a3ea-015f1f4f890c", "name": "Status", "type": "string", "value": "Pending" }, { "id": "2c3340dc-b995-4342-9e51-fff09d3d4ca6", "name": "Measurement Unit", "type": "string", "value": "={{ $json.body['Measurement Unit'] }}" } ] }, "includeOtherFields": "=" }, "typeVersion": 3.4 }, { "id": "47d2bb01-99e6-4ab1-b19d-bc9912243150", "name": "Update Stock", "type": "n8n-nodes-base.code", "position": [ 7440, 3860 ], "parameters": { "jsCode": "const currentStock = parseFloat($input.first().json['Current Stock']\n );\nconst approvedQuantity = parseFloat(\n $('Verify Approval Data').first().json['Approved Quantity']);\nconst newStock = currentStock - approvedQuantity;\n\nif (newStock < 0) throw new Error(`Insufficient stock for ${\n $('Retrieve Issue Request Details').first().json['Product ID']}`);\n\nreturn {\n json: {\n ...$json,\n \"Updated Current Stock\": newStock,\n\"Material Name\":$input.first().json['Material Name'],\"Measurement Unit\":$input.first().json['Measurement Unit'],\n\"Minimum Stock Level\": \n $input.first().json['Minimum Stock Level'],\n \"Issue Date\":\n $('Retrieve Issue Request Details').first().json['Issue Date'],\n\"Product ID\": \n $('Retrieve Issue Request Details').first().json['Product ID']\n \n }\n};" }, "typeVersion": 2 }, { "id": "dcbb196f-1ecf-4137-af29-e511c4b7b9d9", "name": "Receive Issue Request", "type": "n8n-nodes-base.webhook", "position": [ 5900, 3400 ], "webhookId": "73d4bdfc-2d8b-42f4-85d5-43ecae0953c1", "parameters": { "path": "raw-materials-issue", "options": {}, "httpMethod": "POST" }, "typeVersion": 2 }, { "id": "430599b6-3758-4eb7-a924-8530a7c5dc7e", "name": "Send Approval Request", "type": "n8n-nodes-base.gmail", "position": [ 7660, 3400 ], "webhookId": "db24c5e3-8113-4d8a-b562-9c248f47fa3c", "parameters": { "sendTo": "example@gmail.com", "message": "=\n\n
\n \n \nDear XXX,
\nPlease review the following material issue request:
\n\nDear Stock Manager,
\n\nWe have detected a low stock level for the following material:
\n\n \n\nPlease take action to reorder this material.
\n Reorder Now\nDear Stock Manager,
\n\nWe have detected a low stock level for the following material:
\n\n \n\nPlease take action to reorder this material.
\n Reorder Now\n