Author Topic: Deleting Document Templates and Fragments via script  (Read 2506 times)

shimon

  • EA User
  • **
  • Posts: 99
  • Karma: +3/-0
    • View Profile
Deleting Document Templates and Fragments via script
« on: January 31, 2024, 12:03:49 am »
Hi,
I would like a simple script that deletes all documentation fragments and templates (based on the name).
Does anybody have a sample script that does this?

Thanks,
Shimon
P.S. I am a newbie as far as scripting is considered.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12995
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Deleting Document Templates and Fragments via script
« Reply #1 on: January 31, 2024, 12:13:45 am »
I don't think those things are exposed in the API.

So the only option you have is to delete them from the database. IIRC you need to look at t_document
If needed you can execute the deletes from a script.

Geert

shimon

  • EA User
  • **
  • Posts: 99
  • Karma: +3/-0
    • View Profile
Re: Deleting Document Templates and Fragments via script
« Reply #2 on: January 31, 2024, 04:56:41 pm »
Thanks Geert,
That's what I thought, as I didn't find any reference to the objects in the table t_document (after about an hour of searching) in the documentation.
I would rather not go the DB route, so I wanted to combine a SQL search and delete object by GUID, but the t_document doesn't have a GUID and it seems that it is not an element of the Repository. I guess the DB route is the only way.

Sincerely,
Shimon
« Last Edit: January 31, 2024, 05:39:00 pm by shimon »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12995
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Deleting Document Templates and Fragments via script
« Reply #3 on: January 31, 2024, 06:30:33 pm »
Correct, you can't delete them through the API.

There is an undocumented (and unsupported) method in Repository called Execute() that you can call, passing an insert/update/delete query as parameter, so it's not like you need to setup your own database connection to do that.

Geert

shimon

  • EA User
  • **
  • Posts: 99
  • Karma: +3/-0
    • View Profile
Re: Deleting Document Templates and Fragments via script
« Reply #4 on: February 01, 2024, 02:28:18 am »
Wow,
That's great news. I just tried it and it works like a charm.
Thanks,
Shimon