Loading TOC...

MarkLogic 9 Product Documentation
trgr.getTrigger

trgr.getTrigger(
   trigger-name as String
) as element(trgr.trigger)

Summary

Returns the XML representation of a trigger with the given name.

Parameters
trigger-name The trigger name.

Usage Notes

This function must be run in the context of the database containing the trigger to be examined. If no trigger with the name $trigger-name exists, the exception TRGR-TRIGGERDNE is raised.

Example

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

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

trgr.getTrigger("myTrigger");

/* 
<trgr:trigger xmlns:trgr="http://marklogic.com/xdmp/triggers">
       <trgr:trigger-id>7561204940964272849</trgr:trigger-id>
       <trgr:trigger-name>myTrigger</trgr:trigger-name>
       <trgr:description>Simple trigger example</trgr:description>
       <trgr:data-event>
         <trgr:directory-scope>
           <trgr:uri>/myDir/</trgr:uri>
           <trgr:depth>1</trgr:depth>
         </trgr:directory-scope>
         <trgr:document-content>
           <trgr:update-kind>create</trgr:update-kind>
         </trgr:document-content>
         <trgr:when>post-commit</trgr:when>
       </trgr:data-event>
       <trgr:module>
         <trgr:database>10570023054829957732</trgr:database>
         <trgr:root>/modules/</trgr:root>
         <trgr:path>log.json</trgr:path>
       </trgr:module>
       <trgr:enabled>true</trgr:enabled>
       <trgr:recursive>true</trgr:recursive>
       <trgr:task-priority>normal</trgr:task-priority>
     </trgr:trigger> 
*/
   

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