Using triggers with custom procedures

I want to use triggers to track changes in the database and once the trigger is fired I want to call a custom procedure. From the trigger I can pass the transactionId to the procedure. How can I get the transaction metadata in the custom procedure from the transaction Id? Is there any way to fetch the transaction metadata within the user procedure?

CALL apoc.trigger.add('my-trigger',
'
UNWIND apoc.trigger.nodesByLabel($assignedLabels, "Person") AS node
CALL my.change.log(labels(node), node, "name", $transactionId)
RETURN count(*)
'
, {phase:'after'})

Please provide the following information if you ran into a more serious issue:

  • neo4j version - 4.1.1, desktop version = 1.2.7
    Libraries used
    org.neo4j:neo4j:4.1.1
    org.neo4j.driver:neo4j-java-driver:4.1.1

Just sent an PR, see https://github.com/neo4j-contrib/neo4j-apoc-procedures/pull/1673
This should be part of next apoc release for 4.1.

1 Like