Loading TOC...

alert.createTriggers

alert.createTriggers(
   uri as String,
   events as element(trgr.dataEvent)[]
) as Array

Summary

Create triggers that invoke the standard alerting trigger module. The caller must have the alert-admin privilege. The returned trigger IDs must be associated with the config using alert.configSetTriggerIds and then saving the updated config with alert.configInsert.

Parameters
uri The URI specified to alert.makeConfig.
events Events for which to create triggers.

Example

  const alert = require("/MarkLogic/alert.xqy");
  const trgr = require("/MarkLogic/triggers.xqy");

  declareUpdate();
  alert.configInsert(
      alert.configSetTriggerIds(
          alert.configGet("http://acme.com/alert/message-board"),
          alert.createTriggers(
             "http://acme.com/alert/message-board", 
              trgr.triggerDataEvent(
                   trgr.directoryScope("/myDir/", "1"),
                   trgr.documentContent("create"),
                   trgr.postCommit()))))
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.