Supertool script which duplicates dates from related citations to Residence events

A small Supertool script which duplicates dates from related citations to Residence events. It works for cases only when Residence has exactly one citation.

[Gramps SuperTool script file]
version=1

[title]
Update Residence Date

[description]
# This script sets the Residence event date to be the same as its single Citation date

[category]
People

[initial_statements]

[statements]
# Loop through all people in the database
personId = gramps_id
personHandle = handle
personEventRefList = []

# Loop through all events associated with the person
for commonEvent in events:
    # Only process Residence events
    if commonEvent.type != 'Residence':
        continue
    # Skip events that do not have multiple citations
    if len(commonEvent.citations) != 1:
        continue

    commonEventObj = commonEvent.obj
    commonEventDateObject = commonEventObj.get_date_object()  
    
    citation = commonEvent.citations[0]
    citationObj = citation.obj
    citationDateObject = citationObj.get_date_object()

    # If the event date and citation date are not equal, update the event date
    if not commonEventDateObject.is_equal(citationDateObject):
        print(f"{commonEventDateObject.get_dmy()} != {citationDateObject.get_dmy()}")
        commonEventObj.set_date_object(citationDateObject)
        db.commit_event(commonEventObj, trans)
        print(f"Person {personId} events updated successfully")

[filter]

[expressions]

[scope]
all

[unwind_lists]
True

[commit_changes]
False

[summary_only]
False

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