1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Adding tag to Document not working

Adding tag to Document not working

9 posts, 0 answered
  1. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    02 Aug 2011
    Link to this post
    I'm trying to add tags to a document programmatically using the examples (http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-associating-items-with-taxa.html), but it's not quite working. 

    Here's my code:

    var taxonId = new Guid("d349c5b0-a23e-4c44-8415-5f44617e0f72");
    var documentId = new Guid("22d9dd0e-4db3-44bd-8d36-38bfe1664177");
     
    var libManager = LibrariesManager.GetManager();
    var doc = libManager.GetDocument(documentId);
    doc.Organizer.AddTaxa("Tags", taxonId);
    libManager.SaveChanges();

    When I go to that document, it doesn't appear to have any tags. Something is being saved because the sf_media_content_tags table does have a record for the above taxon and document IDs. 

    Am I missing something?
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    05 Aug 2011
    Link to this post
    Hello David,

    Please accept our sincere apologies for the inconvenience caused. I have successfully reproduced the mentioned behavior, and indeed the tags get added to the content item properly, however they are not displayed in the backend Libraries. I have logged  a bug in our system, and we'll be working on providing a fix for it for the upcoming releases. Your Telerik points have been updated accordingly.



    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    09 Aug 2011
    Link to this post
    Is there a PITS number I can track? 

    Thanks,
    David
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Aug 2011
    Link to this post
    Hi David,

    Currently the issue is added for fixing in Q3 release and it is set with higher priority. The issue is logged in our internal system and we have not exposed PITS for it at this stage.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    10 Aug 2011
    Link to this post
    Hi Ivan,

    Thanks for the reply. This is almost a showstopper for us, as we rely on setting the tags (and categories) for our documents. Is there a workaround using the database? I can't figure out which database table isn't being populated.

    Thanks again,
    David
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Aug 2011
    Link to this post
    Hello David,

    I've escalated the problem and we will try to fix it for one of the first internal builds that we will make available for 4.2. This issue will go for sure in 4.2 SP1, which is tentatively scheduled for mid of September. 

    Kind regards,
    Georgi
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    16 Aug 2011
    Link to this post
    Thank you. 
  8. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    08 Sep 2011
    Link to this post
    Hello David,

    Just a quick follow-up: we have just tested the functionality in our latest officially supported version (Sitefinity 4.2) and everything seems to be working properly. One important thing, that I might have missed mentioning lat time, is that you'll have to make sure that you're not applying the Tag to a state of the document that is not the master state, in which case you won't have it displayed in the backend, since what you see when you click on a documents under Content->Documents and Files is a draft copy created from the master copy of the document. The below sample code will properly assign a tag to your documents, please try it out and let us know if any issues persist.

    var taxManager = TaxonomyManager.GetManager();
                var taxon = taxManager.GetTaxa<FlatTaxon>().Where(t => t.Name == "Test").Single();
                LibrariesManager libManager = LibrariesManager.GetManager();
                var myDocument = libManager.GetDocuments().Where(d => d.Title == "ChatLog Issues");
                foreach(var doc in myDocument)
                {
                    doc.Organizer.AddTaxa("Tags", taxon.Id);
                }
                libManager.SaveChanges();


    All the best,
    Boyan Barnev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  9. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    16 Sep 2011
    Link to this post
    Thanks for the follow-up. I had actually found this same solution while working on a couple other document issues. (This was after upgrading to 4.2.) 

    Thanks again,
    David
9 posts, 0 answered