# Class Trigger

Trigger class

#### Implements

- AbstractTrigger

- Defined in packages/saltcorn-data/models/trigger.ts:37

##### Index

### Constructors

constructor

### Properties

action
channel?
configuration
description?
id?
min_role?
name?
run?
table_id?
table_name?
when_trigger

### Accessors

toJson
abbreviated_actions
when_options

### Methods

clone
delete
getTags
haltOnOnlyIf
runWithoutRow
action_options
actionsNotRequiringRow
create
emitEvent
find
findAllWithTableName
findDB
findOne
getAllTableTriggers
getTableTriggers
hasTableTriggers
runTableTriggers
sendEventToServer
setRunFunctions
state_refresh
trigger_actions
update

## Constructors

### constructor

- new Trigger(o: TriggerCfg): Trigger

  Trigger constructor

  #### Parameters

  - o: TriggerCfg

  #### Returns Trigger

  - Defined in packages/saltcorn-data/models/trigger.ts:54

## Properties

### action

action: string

Implementation of AbstractTrigger.action

- Defined in packages/saltcorn-data/models/trigger.ts:39

### `Optional` channel

channel?: string

Implementation of AbstractTrigger.channel

- Defined in packages/saltcorn-data/models/trigger.ts:44

### configuration

configuration: any

Implementation of AbstractTrigger.configuration

- Defined in packages/saltcorn-data/models/trigger.ts:46

### `Optional` description

description?: string

Implementation of AbstractTrigger.description

- Defined in packages/saltcorn-data/models/trigger.ts:40

### `Optional` id

id?: number | null

Implementation of AbstractTrigger.id

- Defined in packages/saltcorn-data/models/trigger.ts:45

### `Optional` min_role

min_role?: number

Implementation of AbstractTrigger.min_role

- Defined in packages/saltcorn-data/models/trigger.ts:47

### `Optional` name

name?: string

Implementation of AbstractTrigger.name

- Defined in packages/saltcorn-data/models/trigger.ts:38

### `Optional` run

run?: (row: Row, extraArgs?: any) => Promise<any>

- Defined in packages/saltcorn-data/models/trigger.ts:48

### `Optional` table_id

table_id?: number | null

Implementation of AbstractTrigger.table_id

- Defined in packages/saltcorn-data/models/trigger.ts:41

### `Optional` table_name

table_name?: string

Implementation of AbstractTrigger.table_name

- Defined in packages/saltcorn-data/models/trigger.ts:42

### when_trigger

when_trigger: string

Implementation of AbstractTrigger.when_trigger

- Defined in packages/saltcorn-data/models/trigger.ts:43

## Accessors

### toJson

- get toJson(): any

  Get JSON from Trigger

  #### Returns any

  Implementation of AbstractTrigger.toJson

  - Defined in packages/saltcorn-data/models/trigger.ts:78

### `Static` abbreviated_actions

- get abbreviated_actions(): {
  disableInBuilder: boolean;
  disableInWorkflow: boolean;
  hasConfig: boolean;
  name: string;
  namespace: any;
  requireRow: boolean;
  }[]

  #### Returns {
  disableInBuilder: boolean;
  disableInWorkflow: boolean;
  hasConfig: boolean;
  name: string;
  namespace: any;
  requireRow: boolean;
  }[]

  - Defined in packages/saltcorn-data/models/trigger.ts:702

### `Static` when_options

- get when_options(): string[]

  Trigger when options

  #### Returns string[]

  - Defined in packages/saltcorn-data/models/trigger.ts:640

## Methods

### clone

- clone(): Promise<Trigger>

  Clone page

  #### Returns Promise<Trigger>

  Implementation of AbstractTrigger.clone

  - Defined in packages/saltcorn-data/models/trigger.ts:670

### delete

- delete(): Promise<void>

  Delete current trigger

  #### Returns Promise<void>

  Implementation of AbstractTrigger.delete

  - Defined in packages/saltcorn-data/models/trigger.ts:188

### getTags

- getTags(): Promise<AbstractTag[]>

  #### Returns Promise<AbstractTag[]>

  Implementation of AbstractTrigger.getTags

  - Defined in packages/saltcorn-data/models/trigger.ts:697

### haltOnOnlyIf

- haltOnOnlyIf(row: Row, user?: Row): boolean

  Check if the trigger should halt based on the _only_if condition.

  #### Parameters

  - row: Row

    The row data.

  - `Optional` user: Row

    The user data.

  #### Returns boolean

  - Returns true if the _only_if condition exists and evaluates to falsy.

  Implementation of AbstractTrigger.haltOnOnlyIf

  - Defined in packages/saltcorn-data/models/trigger.ts:531

### runWithoutRow

- runWithoutRow(runargs?: any): Promise<any>

  Run trigger without row

  #### Parameters

  - runargs: any = {}

  #### Returns Promise<any>

  Implementation of AbstractTrigger.runWithoutRow

  - Defined in packages/saltcorn-data/models/trigger.ts:414

### `Static` action_options

- action_options(
  __namedParameters: {
  apiNeverTriggers?: boolean;
  builtInLabel?: string;
  builtIns?: string[];
  forBuilder?: boolean;
  forWorkflow?: boolean;
  noMultiStep?: boolean;
  notRequireRow?: boolean;
  tableTriggers?: number;
  workflow?: boolean;
  },
  ): any[]

  #### Parameters

  - __namedParameters: {
    apiNeverTriggers?: boolean;
    builtInLabel?: string;
    builtIns?: string[];
    forBuilder?: boolean;
    forWorkflow?: boolean;
    noMultiStep?: boolean;
    notRequireRow?: boolean;
    tableTriggers?: number;
    workflow?: boolean;
    }

  #### Returns any[]

  - Defined in packages/saltcorn-data/models/trigger.ts:778

### `Static` actionsNotRequiringRow

- actionsNotRequiringRow(): string[]

  #### Returns string[]

  - Defined in packages/saltcorn-data/models/trigger.ts:723

### `Static` create

- create(f: TriggerCfg): Promise<Trigger>

  Create trigger

  #### Parameters

  - f: TriggerCfg

  #### Returns Promise<Trigger>

  - Defined in packages/saltcorn-data/models/trigger.ts:170

### `Static` emitEvent

- emitEvent(
  eventType: string,
  channel?: string | null,
  userPW?: object | User,
  payload?: any,
  ): void

  Emit an event: run associated triggers

  #### Parameters

  - eventType: string
  - channel: string | null = null
  - `Optional` userPW: object | User = {}
  - `Optional` payload: any

  #### Returns void

  - Defined in packages/saltcorn-data/models/trigger.ts:222

### `Static` find

- find(where?: Where): Trigger[]

  Find triggers in State cache

  #### Parameters

  - `Optional` where: Where

    condition

  #### Returns Trigger[]

  - Defined in packages/saltcorn-data/models/trigger.ts:102

### `Static` findAllWithTableName

- findAllWithTableName(): Promise<Trigger[]>

  Find all triggers

  #### Returns Promise<Trigger[]>

  - Defined in packages/saltcorn-data/models/trigger.ts:125

### `Static` findDB

- findDB(where?: Where, selectopts?: SelectOptions): Promise<Trigger[]>

  Find triggers in DB

  #### Parameters

  - `Optional` where: Where
  - `Optional` selectopts: SelectOptions

  #### Returns Promise<Trigger[]>

  - Defined in packages/saltcorn-data/models/trigger.ts:113

### `Static` findOne

- findOne(where: Where): any

  Find one trigger in State cache

  #### Parameters

  - where: Where

  #### Returns any

  - Defined in packages/saltcorn-data/models/trigger.ts:139

### `Static` getAllTableTriggers

- getAllTableTriggers(table: AbstractTable): Trigger[]

  get triggers for a table with all when options

  #### Parameters

  - table: AbstractTable

  #### Returns Trigger[]

  - Defined in packages/saltcorn-data/models/trigger.ts:626

### `Static` getTableTriggers

- getTableTriggers(
  when_trigger: string,
  table: AbstractTable | null,
  user?: Row,
  ): Trigger[]

  get triggers

  #### Parameters

  - when_trigger: string
  - table: AbstractTable | null
  - `Optional` user: Row

  #### Returns Trigger[]

  - Defined in packages/saltcorn-data/models/trigger.ts:588

### `Static` hasTableTriggers

- hasTableTriggers(when_trigger: string, table: AbstractTable): boolean

  get triggers

  #### Parameters

  - when_trigger: string
  - table: AbstractTable

  #### Returns boolean

  - Defined in packages/saltcorn-data/models/trigger.ts:611

### `Static` runTableTriggers

- runTableTriggers(
  when_trigger: string,
  table: AbstractTable | null,
  row: Row,
  resultCollector?: any,
  user?: Row,
  extraArgs?: any,
  ): Promise<void>

  Run table triggers

  #### Parameters

  - when_trigger: string
  - table: AbstractTable | null
  - row: Row
  - `Optional` resultCollector: any
  - `Optional` user: Row
  - `Optional` extraArgs: any

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/trigger.ts:355

### `Static` sendEventToServer

- sendEventToServer(
  eventType: string,
  channel?: string | null,
  user?: {},
  payload?: any,
  ): Promise<void>

  #### Parameters

  - eventType: string
  - channel: string | null = null
  - user: {} = {}
  - `Optional` payload: any

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/trigger.ts:198

### `Static` setRunFunctions

- setRunFunctions(
  triggers: Trigger[],
  table: AbstractTable | null,
  user?: Row,
  ): void

  #### Parameters

  - triggers: Trigger[]
  - table: AbstractTable | null
  - `Optional` user: Row

  #### Returns void

  - Defined in packages/saltcorn-data/models/trigger.ts:544

### `Static` state_refresh

- state_refresh(): Promise<void>

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/trigger.ts:146

### `Static` trigger_actions

- trigger_actions(
  __namedParameters: {
  apiNeverTriggers?: boolean;
  noWorkflows?: boolean;
  tableTriggers?: number;
  },
  ): string[]

  #### Parameters

  - __namedParameters: { apiNeverTriggers?: boolean; noWorkflows?: boolean; tableTriggers?: number }

  #### Returns string[]

  - Defined in packages/saltcorn-data/models/trigger.ts:737

### `Static` update

- update(id: number, row: Row): Promise<void>

  Update trigger

  #### Parameters

  - id: number
  - row: Row

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/trigger.ts:156