Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: shimon on January 31, 2024, 12:03:49 am

Title: Deleting Document Templates and Fragments via script
Post by: shimon 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.
Title: Re: Deleting Document Templates and Fragments via script
Post by: Geert Bellekens 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
Title: Re: Deleting Document Templates and Fragments via script
Post by: shimon 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
Title: Re: Deleting Document Templates and Fragments via script
Post by: Geert Bellekens 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
Title: Re: Deleting Document Templates and Fragments via script
Post by: shimon 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