Adding tag to Document not working

Posted by Community Admin on 04-Aug-2018 22:01

Adding tag to Document not working

All Replies

Posted by Community Admin on 02-Aug-2011 00:00

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?

Posted by Community Admin on 05-Aug-2011 00:00

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

Posted by Community Admin on 09-Aug-2011 00:00

Is there a PITS number I can track? 

Thanks,
David

Posted by Community Admin on 10-Aug-2011 00:00

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

Posted by Community Admin on 10-Aug-2011 00:00

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

Posted by Community Admin on 16-Aug-2011 00:00

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

Posted by Community Admin on 16-Aug-2011 00:00

Thank you. 

Posted by Community Admin on 08-Sep-2011 00:00

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

Posted by Community Admin on 16-Sep-2011 00:00

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

This thread is closed