fix issue with automation not triggering when no fields existed

This commit is contained in:
Peter Clement 2024-01-26 09:21:13 +00:00
parent 0efe0bb7ac
commit 58fedd10f5
1 changed files with 17 additions and 19 deletions

View File

@ -160,29 +160,27 @@ const deleteRowHandler = async action => {
const triggerAutomationHandler = async action => {
const { fields, notificationOverride, timeout } = action.parameters
if (fields) {
try {
const result = await API.triggerAutomation({
automationId: action.parameters.automationId,
fields,
timeout,
})
// Value will exist if automation is synchronous, so return it.
if (result.value) {
if (!notificationOverride) {
notificationStore.actions.success("Automation ran successfully")
}
return { result }
}
try {
const result = await API.triggerAutomation({
automationId: action.parameters.automationId,
fields,
timeout,
})
// Value will exist if automation is synchronous, so return it.
if (result.value) {
if (!notificationOverride) {
notificationStore.actions.success("Automation triggered")
notificationStore.actions.success("Automation ran successfully")
}
} catch (error) {
// Abort next actions
return false
return { result }
}
if (!notificationOverride) {
notificationStore.actions.success("Automation triggered")
}
} catch (error) {
// Abort next actions
return false
}
}
const navigationHandler = action => {