# שימוש חוזר ב-\`external\_id\` לאחר מחיקת נושא

**URL:** https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550
**Category:** Support
**Created:** [30 באוגוסט,‏ 2022,‏ 7:20am UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550 "2022-08-30T07:20:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![george\_m](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/george_m/32/272202_2.png) [@george\_m](https://meta.discourse.org/u/george_m)
#### Post date: [30 באוגוסט,‏ 2022,‏ 7:20am UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/1 "2022-08-30T07:20:20Z")

</div>

We’re using the `external_id` feature for Topic auto-creation in [our integration](https://github.com/linuxdojo/catalogbot). 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:

```plaintext
{'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?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 באוגוסט,‏ 2022,‏ 10:17am UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/2 "2022-08-30T10:17:34Z")

</div>

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](https://meta.discourse.org/t/introducing-permanently-delete-post-functionality/207109) might be how).

---

<div class="post-metadata">

### Author: ![george\_m](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/george_m/32/272202_2.png) [@george\_m](https://meta.discourse.org/u/george_m)
#### Post date: [30 באוגוסט,‏ 2022,‏ 12:04pm UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/3 "2022-08-30T12:04:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 באוגוסט,‏ 2022,‏ 12:26pm UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/4 "2022-08-30T12:26:54Z")

</div>

Unless those integers are really expensive? 🤔

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

---

<div class="post-metadata">

### Author: ![george\_m](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/george_m/32/272202_2.png) [@george\_m](https://meta.discourse.org/u/george_m)
#### Post date: [30 באוגוסט,‏ 2022,‏ 12:41pm UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/5 "2022-08-30T12:41:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [29 בספטמבר,‏ 2022,‏ 12:42pm UTC](https://meta.discourse.org/t/re-use-of-external-id-after-a-topic-is-deleted/237550/6 "2022-09-29T12:42:13Z")

</div>

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