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.