Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Taxonomy Term in custom list field.

$
0
0

Hi
Can someone help!

I have a custom list with a user field and a field having multiple values ​​of Taxonomy Term. Termset called interests.
Form a checkboxlist users can choose Term (interests) and then update the updata the list.
Simple operation! wrong.
I have no problems getting the name and GUID for each Term in both the custom list field and from the team the store. But I can´t update the listItem.

SPSite site = SPContext.Current.Site;
TermSet interests = GetTermSet();// Get all Term of interests
// var listTerms = new List<Term>(); // have also tried this.
foreach (System.Web.UI.WebControls.ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
Guid g = new Guid(item.Value);
Term term = interests.GetTerm(g);
string wssId = GetWssIdsOfTerm(site, term); //some wssId is empty, How can it be?
//listTerms.Add(term);
li.Add(wssId + ";#" + item.Text.Trim() + '|' + item.Value.Trim()); 
}
}
SPWeb web = site.RootWeb;
SPList interestsList = web.Lists["interests"];
// --------------------------------------
var collListItem = interestsList.GetItems(query);
SPListItem myitem = collListItem[0];
myitem["Myinterests"] = li; //This empties only the field
// myitem["Interesser"] = "23;#Annoncering|89a65ded-d788-40e0-a4e7-8ce6c62c784b";//This works but not for several values
myitem.Update(); 
hope that someone knows how this problem can be solved.


Best regards Christian.

udvikler


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>