# APOC Trigger to add property to newly created relations

**URL:** <https://community.neo4j.com/t/apoc-trigger-to-add-property-to-newly-created-relations/18862>\
**Category:** Procedures & APOC\
**Created:** [May 19, 2020, 7:42am UTC](https://community.neo4j.com/t/apoc-trigger-to-add-property-to-newly-created-relations/18862 "2020-05-19T07:42:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrei.constantin](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrei.constantin/32/4113_2.png) [@andrei.constantin](https://community.neo4j.com/u/andrei.constantin)\
**Post date:** [May 19, 2020, 7:42am UTC](https://community.neo4j.com/t/apoc-trigger-to-add-property-to-newly-created-relations/18862/1 "2020-05-19T07:42:51Z")

</div>

Hello everyone!

I've been struggling to implement a trigger that adds the timestamp of a relation's creation as its property. I've seen this [post](https://community.neo4j.com/t/apoc-triggers-to-automatically-add-properties/9349) and I found it really useful, where after changing the syntax to my neo4j version (Community 4.0.0) I made it work with newly created nodes using this trigger:

```auto
CALL apoc.trigger.add('node_add_time',"UNWIND $createdNodes AS n
  SET n.creation_date = apoc.date.format(timestamp())", {phase:'after'})

```

Here is the trigger where I've tried to do the same with relations but didn't work:

```auto
CALL apoc.trigger.add("rel_add_time", "UNWIND $createdRelationships AS rel 
  SET rel.creation_date = apoc.date.format(timestamp())", {phase:'after'})

```

The problem I've been facing is the fact that the relations are created, but the query gets stuck loading in the browser, and the properties are not set. I've tried a couple of example queries that are run over a db that already has 300k nodes and 600k rels, I don't know if this has something to do, but here are the examples that I've been using to test (The browser gets stuck executing the second query).

`CREATE(node : MYNODE { name : 'node1'}) CREATE(node2 : MYNODE { name : 'node2'})`

`match (node : MYNODE) match (node2 : MYNODE) where node2 <> node merge (node)<-[:TEST]-(node2)`

The label MYNODE is not previously in the DB, this 2 are the only occurences.

If you have any suggestion on what could be going wrong or if you have any other implementation that you think could do the job better than this one I'm all ears!

Thanks for you time.

PD: My APOC version is 4.0.0.2
