You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Triggers

Explicit trigger (button)

triggers ({ on }) {
  return on('manual')
    .for('compose:record')
    .uiProp('app', 'compose')
},
triggers ({ on }) {
  return on('manual')
    .for('compose:record')
    .where('module', 'Module1')
    .uiProp('app', 'compose')
},

Implicit trigger (automatic)

// Before something
triggers ({ before }) {
  // You can pass in multiple events: create, update, delete
  return before('create', 'update')
      .for('compose:record')
      .where('module', 'Module1')
},

// After something
triggers ({ after }) {
  // You can pass in multiple events: create, update, delete
  return after('create', 'update')
      .for('compose:record')
      .where('module', 'Module1')
},

// After where record value 'Name' is 'John'
triggers ({ after }) {
  return after('create', 'update')
      .where('module', 'Module1')
      .where('record.values.Name', 'John')
},

// After user is created/updated, where email ends with @corteza.com
triggers ({ after }) {
  return after('create', 'update')
      .for('system:user')
      .where('user.email', '^[a-zA-Z0-9]{1,20}@corteza.com$')
},

Deferred (interval)

// Every day at 2AM
triggers ({ on }) {
  return on('interval')
    .every('0 2 * * *')
},

// Every 4th month at 12:00 AM
triggers ({ on }) {
  return on('interval')
    .every('00 12 1 */4 *')
},

Deferred (timestamp)

// On christmas eve
triggers ({ at }) {
    // You can pass multiple timestamps (timestamp1, timestamp2, ..., timestampN)
  return at('2020-12-24T21:00:00Z')
},

On HTTP request

// When POST request on a certain path is recieved
triggers ({ on }) {
  return on('request')
    .where('request.path', '/some/path/here')
    // HTTP protocol; GET, POST, PUT, PATCH, DELETE
    .where('request.method', 'POST')
    .for('system:sink'),
},

// If request.headers authorization is empty
triggers ({ on }) {
  return on('request')
    .where('request.path', '/some/path/here')
    // HTTP protocol; GET, POST, PUT, PATCH, DELETE
    .where('request.headers.authorization', '')
    .for('system:sink'),
},