Loading TOC...

trgr.triggerSetEvent

trgr.triggerSetEvent(
   trigger-name as String,
   event as Node
) as null

Summary

Assigns a triggering event to the named trigger.

Parameters
trigger-name The trigger name.
event An event definition. Use trgr.triggerDataEvent or trgr.triggerDatabaseOnlineEvent to construct this element.

Usage Notes

A trigger event describes the conditions under which the trigger fires. After calling this function, any previous event associated with the trigger is replaced.

This function must be run in the context of the database containing the trigger to be modified.

If the named trigger does not exist, the exception TRGR-TRIGGERDNE is raised.

Example

// Run in the context of the database containing the trigger.

declareUpdate();
const trgr = require('/MarkLogic/triggers');

trgr.triggerSetEvent(
  'myTrigger', 
  trgr.triggerDataEvent(
    trgr.directoryScope('/myDir/', '1'),
    trgr.documentContent('create'),
    trgr.postCommit()));

// Empty sequence. The trigger 'myTrigger' is set to fire 
// whenever a document is created in '/myDir/'. The trigger 
// module runs after the creating transaction is committed.
   

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