TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Get WSS ID from Term using Server Side Object Model
Prasham Sabadra
May 17
2015
Code
1.9
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
int
FetchWssIdByTerm(SPWeb rootWeb, Term term)
{
int
wssID;
if
(rootWeb.Properties.ContainsKey(
"TaxonomyHiddenList"
))
{
Guid taxonomyHiddenListId =
new
Guid(rootWeb.Properties[
"TaxonomyHiddenList"
]);
SPList taxonomyHiddenList = rootWeb.Lists[taxonomyHiddenListId];
SPQuery query =
new
SPQuery();
query.Query =
string
.Format(@
"<Where><And>
<Eq><FieldRef Name=
'IdForTerm'
/>
<Value Type=
'Text'
>{0}</Value>
</Eq>
<Eq><FieldRef Name=
'IdForTermSet'
/>
<Value Type=
'Text'
>{1}</Value>
</Eq>
</And>
</Where>", term.Id, term.TermSet.Id);
SPListItemCollection items = taxonomyHiddenList.GetItems(query);
if
(items.Count > 0) {
wssID =
int
.Parse(items[0][
"ID"
].ToString());
}
}
return
wssID;
}
WSS ID
Getting WSS ID from term