Some quick automation fixes.

This commit is contained in:
mike12345567 2020-10-02 16:42:47 +01:00
parent 7594b17ec7
commit e43e0e100b
3 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,5 @@
const sendEmail = require("./steps/sendEmail")
const saveRecord = require("./steps/saveRecord")
const createRecord = require("./steps/createRecord")
const updateRecord = require("./steps/updateRecord")
const deleteRecord = require("./steps/deleteRecord")
const createUser = require("./steps/createUser")
@ -17,14 +17,14 @@ const DEFAULT_DIRECTORY = ".budibase-automations"
const AUTOMATION_MANIFEST = "manifest.json"
const BUILTIN_ACTIONS = {
SEND_EMAIL: sendEmail.run,
SAVE_RECORD: saveRecord.run,
CREATE_RECORD: createRecord.run,
UPDATE_RECORD: updateRecord.run,
DELETE_RECORD: deleteRecord.run,
CREATE_USER: createUser.run,
}
const BUILTIN_DEFINITIONS = {
SEND_EMAIL: sendEmail.definition,
SAVE_RECORD: saveRecord.definition,
CREATE_RECORD: createRecord.definition,
UPDATE_RECORD: updateRecord.definition,
DELETE_RECORD: deleteRecord.definition,
CREATE_USER: createUser.definition,

View File

@ -2,12 +2,12 @@ const recordController = require("../../api/controllers/record")
const automationUtils = require("../automationUtils")
module.exports.definition = {
name: "Save Record",
tagline: "Save a {{inputs.enriched.model.name}} record",
name: "Create Record",
tagline: "Create a {{inputs.enriched.model.name}} record",
icon: "ri-save-3-fill",
description: "Save a record to your database",
description: "Create a record to your database",
type: "ACTION",
stepId: "SAVE_RECORD",
stepId: "CREATE_RECORD",
inputs: {},
schema: {
inputs: {

View File

@ -55,7 +55,15 @@ module.exports.definition = {
}
module.exports.run = async function filter({ inputs }) {
const { field, condition, value } = inputs
let { field, condition, value } = inputs
// coerce types so that we can use them
if (!isNaN(value) && !isNaN(field)) {
value = parseFloat(value)
field = parseFloat(field)
} else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
value = Date.parse(value)
field = Date.parse(field)
}
let success
if (typeof field !== "object" && typeof value !== "object") {
switch (condition) {