Re-use of `external_id` after a Topic is deleted

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).

Hi @pfaffman
Thanks very much for the suggestion and for the nudge in giving more thought to external_id reuse in general.

1 Like

Unless those integers are really expensive? :thinking:

(Glad that I seemed helpful rather than sarcastic!) Hope you find a good solution.

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.

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