MarkLogic 9 Product Documentation
trgr.triggerSetModule

trgr.triggerSetModule(
   trigger-name as String,
   module as element(trgr.module)
) as null

Summary

Sets or replaces the action module associated with the named trigger.

Parameters
trigger-name The trigger name.
module A module definition. Use trgr:trigger-module to construct this parameter.

Usage Notes

When $trigger fires, $module is evaluated. Any module previously associated with $trigger is replaced when this function is called.

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.triggerSetModule(
  'myTrigger', 
  trgr.triggerModule(
    xdmp.database('MyTriggers'), 
    '/modules/',
    'theNewAction.xml'));

// Empty sequence. When 'myTrigger' fires, "theNewAction.json" 
// is evaluated.
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy