6

I have a keyword taxonomy that I'm retrieving from the Broker DB, and the keywords have a metadata schema that includes a link to another keyword.

When I use (pseudocode):

taxonomy = taxonomyFactory.GetTaxonomyKeywords([taxonomyUri] ...)
taxonomy.KeywordChildren.Cast<Keyword>().Select(c => c.KeywordMeta.GetValue("[keywordFieldName]")

I end up with a TCM ID for each keyword's [keywordFieldName] that looks like: "tcm:0-87-1024" - if I check that TCM ID I get a tcm:Error:

Unable to read Keyword

The item tcm:0-87-1024 does not exist.

If I swap the '0' for a '9' everything works fine.

  • Have you checked what you are passing in as taxonomyUri? – Dominic Cronin Dec 6 '13 at 12:11
  • 1
    Based on your observation, your taxonomy URI should be something like tcm:9-...-512, as Dominic has suggested, check its value that you are passing in the line - taxonomy = taxonomyFactory.GetTaxonomyKeywords([taxonomyUri] ...) – Pankaj Gaur Dec 6 '13 at 12:18
  • Sorry, the pseudocode doesn't make it clear, but the result of the taxonomy request line seems to be fine - I'm using that already in a few places - getting KeywordChildren and values from the Meta etc. By the by - it is tcm:9-x-512. – Ian Grainger Dec 6 '13 at 12:42
3

As you say in your comment, the .KeywordChildren part of this is correct and is working elsewhere.

The problem appears to be the the link to another Keyword, from within the Metadata of the original Keyword, does not give the Publication part in the TcmId (i.e. it is returning 'tcm:0-87-1024' instead of 'tcm:9-87-1024' when you are searching in a Category in Publication number 9).

It appears that this is by design.

Looking at Raimond's answer here, where the is a link to a Component from within Keyword Metadata, this also is returning TcmIds in the form tcm:0-<id>

I cannot find anywhere within the online documentation or API documentation where this is described.

I suspect that when you try to get the Keyword, you will have to get the Publication ID part from the Application Settings.

            var keyword = new TaxonomyFactory().GetTaxonomyKeyword(new TcmId(System.Configuration.ConfigurationManager.AppSettings["PublicationID"], keywordId, 1024).ToString());
            //keywordId here would be 87
                if (keyword != null)
                {
                ...
                {
| improve this answer | |
  • OK - that's almost the same the workaround I had - which went: well, 0 is clearly wrong, if I see that just replace it with 9 ;) Yours makes a lot more sense than that, clearly - but the effect is the same... – Ian Grainger Dec 6 '13 at 16:23
  • Thanks Ian. I'm glad it works. If anyone knows the reason for this behaviour, I would be interested to know. – Jonathan Williams Dec 6 '13 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.