Much thanks, all parts!
So, I expect to run multiple instances of Discourse, as well as an overarching (non-Discourse) admin/coordination system in the background. Topics will get added to Discourse in one of 2 ways - either by users via the usual Discourse topic-creation mechanism, or by the admin/coordination system via the API.
Where the topic is created via the API, it will typically represent a task or similar workflow item which will already have it’s own non-Discourse ID … lets call it the “External ID”.
Where the topic is created by the user within Discourse, we’ll use webhooks to trigger an Azure function to create a stub-like clone within the central system (so that the Discourse messages gets connected into a wider stream of content, tasks etc). Therefore, again, the Discourse Topic indirectly will have a unique “External ID” - which we propose to update the Topic with, via the API.
We have a bespoke Discourse theme component which, as each topic loads, will use Ajax to retrieve non-Discourse-centric information from the central system and to display this on the Topic screen.
While we could use the Discourse Topic ID to parameterise the Ajax call and find the matching data, its more efficient to use the “External ID” to do so (it’s just cleaner, multiple reasons - it avoids lookups etc).
We could easily store the “External ID” in a custom field - we already have one for other data - but we notice that the Topics API has an “external_id” field that looks exactly like what we need, and I’d prefer to use it for various reasons … it just makes this somewhat-pivotal field easier to incorporate in reports, exports, maybe future searches etc.
See the screengrab from the Discourse API Docs
I’m guessing this is a rather new field - most of the advice in the forum seems to relate to the User external_id field, which is not what I need right now. As mentioned above, I am retrieving the Ember model for the topic (within my custom theme component) and I can get just about all info about the topic through it … but not the external_id field.
(As above - I am getting the topic using this code, borrowed from somewhere on this site, no idea where at this stage:
const topicController = api.container.lookup("controller:topic");
if (topicController) {
const thisTopic = topicController.get("model");
So, the request - is the topic-specific external_id field buried in the model (“thisTopic”) somewhere, or am I misunderstanding these concepts and should I just use the custom field to store this external ID (I know I can get that approach to work, and how! … I just prefer the cleanliness and future-readiness of using the distinct external_id, if indeed its available).
Again, thanks for the help, I appreciate it!