n8n-nodes-smartsuite
Version:
n8n community node for SmartSuite
45 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execute = execute;
const n8n_workflow_1 = require("n8n-workflow");
const utils_1 = require("../../helpers/utils");
const smartSuiteApi_1 = require("../../transport/smartSuiteApi");
const validation_1 = require("../../helpers/validation");
async function execute() {
(0, utils_1.debugLog)('[Table] createTable.execute called', this.getNode().parameters, 2);
// 1) Validate solution
const solutionId = await validation_1.getSolutionId.call(this, 0);
// 2) Gather inputs
const tableName = this.getNodeParameter('tableName', 0);
const tableDescription = this.getNodeParameter('tableDescription', 0);
const icon = this.getNodeParameter('icon', 0);
if (!tableName.trim()) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Table name cannot be blank.');
}
// 3) Build payload
const body = {
name: tableName,
solution: solutionId,
description: tableDescription,
icon,
structure: [
{
slug: 'title',
label: 'Title',
field_type: 'recordtitlefield',
},
],
};
(0, utils_1.debugLog)('[Table] createTable.payload', body, 2);
const returnData = [];
try {
const response = await smartSuiteApi_1.apiRequest.call(this, 'POST', '/applications/', body);
(0, utils_1.debugLog)('[Table] createTable.response', response, 2);
returnData.push({ json: { success: true, data: response } });
}
catch (err) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), err.message);
}
return returnData;
}
//# sourceMappingURL=createTable.operation.js.map