# Supertool. How add an existing note and date to an event?

**URL:** <https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552>\
**Category:** Help\
**Created:** [June 1, 2024, 6:25pm UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552 "2024-06-01T18:25:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)\
**Post date:** [June 1, 2024, 6:25pm UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552/1 "2024-06-01T18:25:21Z")

</div>

I have a short question. What is wrong in my code fragment? It does not add the note. Commit checkbox is turned on.

```python
note = db.get_note_from_gramps_id("N1823")
print(note.gramps_id, note.handle)

if (gramps_id == "I9968"):
    birth.obj.add_note(note.handle)

```

![Screenshot from 2024-06-01 21-20-23](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/5/515f9d08dd154d321e8a4c54ecb1924c79d7d21c.png)

---

<div class="post-metadata">

**Author:** ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)\
**Post date:** [June 1, 2024, 6:41pm UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552/2 "2024-06-01T18:41:37Z")

</div>

And also tried commit manually:

```python
note = db.get_note_from_gramps_id("N1823")
print(note.gramps_id, note.handle)

if (gramps_id == "I9968"):
    birth.obj.add_note(note.handle)
    event_date = Date()
    event_date.set(
        modifier=Date.MOD_RANGE, 
        value=(0, 0, 1900, False, 0, 0, 1990, False)
    )
    birth.obj.set_date_object(event_date)
    db.commit_event(birth.obj, trans)
    birth._commit(db, trans)
    print("commited")

```

Still doesn’t work

---

<div class="post-metadata">

**Author:** ![kku](https://avatars.discourse-cdn.com/v4/letter/k/6bbea6/32.png) [@kku](https://gramps.discourse.group/u/kku)\
**Post date:** [June 2, 2024, 5:29am UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552/3 "2024-06-02T05:29:52Z")

</div>

The reason is explained in the SuperTool README:

```
https://github.com/Taapeli/isotammi-addons/blob/master/source/SuperTool/README.md#proxy-objects

```

Excerpt:

Proxy objects are created when they are needed. This means also that identical expressions do not always refer to the same objects.  
For example, in People category, the expression birth.place.obj refers to a Gramps internal Place object. But if you use the same expression multiple times in the same query then each one will refer to a different Place object. This matters only if you intend to update the object - changes in one object will not be seen in the other and calling db.commit\_place() would not have any effect. Solution is to save the object reference in a local variable, e.g.

```
# does not work:
birth.place.obj.set_latitude(90)
db.commit_place(birth.place.obj, trans)

# ok:
placeobj = birth.place.obj
placeobj.set_latitude(90)
db.commit_place(placeobj, trans)    

```

So you would have to do something like:

```
if (gramps_id == "I9968"):
    birth_obj = birth.obj
    birth_obj.add_note(note.handle)
    db.commit_event(birth_obj, trans)

```

So this is a flaw in the design of SuperTool. Sorry about that!

You need to commit explicitly because the “Commit changes” checkbox only affects the current category (i.e. Person objects in this case).

---

<div class="post-metadata">

**Author:** ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)\
**Post date:** [June 2, 2024, 6:48am UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552/4 "2024-06-02T06:48:08Z")

</div>

@kku It is working now. Beautiful!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)\
**Post date:** [July 2, 2024, 6:48am UTC](https://gramps.discourse.group/t/supertool-how-add-an-existing-note-and-date-to-an-event/5552/5 "2024-07-02T06:48:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
