The discussion revolves around reusing the external_id feature in Discourse after a Topic is deleted. george_m is using external_id for Topic auto-creation in their integration, but encounters an error when trying to reuse the same external_id after deleting a Topic. pfaffman explains that deleted topics are not removed from the database, but can be permanently deleted. However, george_m faces challenges in changing the external_id value due to limitations in the integrated app’s read-only API.
Alternatives such as archiving or hiding topics are considered, but george_m requires further research into Discourse’s features to find a suitable solution. pfaffman suggests that archiving or hiding might be a better approach than deleting topics to avoid the external_id reuse issue.
We’re using the external_id feature for Topic auto-creation in our integration. I note however that if we delete a Topic, we can not create a new one with the same external_id and instead receive the error:
{'action': 'create_post', 'errors': ['External has already been taken']}
Is it at all possible to re-use the same external_id after a Topic that used it is deleted?
I am aware of a workaround discussed elsewhere using custom fields on User objects, however Topic objects don’t appear to support custom fields. Is there a way?
That’s because deleted topics are marked as deleted not removed from the database. Wanting to reassociate an ID with another topic seems like a bad idea (but you didn’t ask). You can force the topic to actually be deleted (Introducing permanently delete post functionality might be how).
The challenge is that the value we’re using for the Topic’s external_id is difficult to change (manual operation) due to a limitation in the app we’re integrating with (CatalogIt - exposes a read only API). We often manually delete and auto-recreate Topics as we develop (this is all the integration does - creates discussion topics for items in CatalogIt when a user clicks a “discus this item” link), forcing us to change this value each time. If the value is not changed after deleting the topic and a user clicks the “discuss this item” link later, we hit the “external already taken” error.
Perhaps archiving rather than deleting is a better idea, or perhaps there is a hide/unhide mechanism we can lean on. I am unfamiliar with Discourse, some research needed, will dig in and see what I can find.