Tôi đang cập nhật quản lý trường dữ liệu meta bằng C#. Sau đây là mã để lấy TermId cho thuật ngữ.Sharepoint 2013 - Phân loại- Microsoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession ”
string termId = string.Empty;
try
{
TaxonomySession tSession = TaxonomySession.GetTaxonomySession(CC);
TermStore termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
TermSet tset = ts.GetTermSet(termSetId); // I have proper Guid here, checked this in SharePoint 2013 server.
LabelMatchInformation lmi = new LabelMatchInformation(CC);
lmi.Lcid = 1033;
lmi.TrimUnavailable = true;
lmi.TermLabel = "xyz"; //Name of the term.
TermCollection termMatches = tset.GetTerms(lmi);
CC.Load(tSession);
CC.Load(ts);
CC.Load(tset);
CC.Load(termMatches);
CC.ExecuteQuery();
if (termMatches != null && termMatches.Count() > 0)
termId = termMatches.First().Id.ToString();
}
catch (Exception ex)
{
var d = ex.Message;
}
return termId;
}
Nhưng tôi nhận được ngoại lệ như: “Không thể gọi phương thức hoặc lấy tài sản từ đối tượng null. Đối tượng được trả về bởi ngăn xếp cuộc gọi sau là null. \ "GetDefaultSiteCollectionTermStore \ r \ nMicrosoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”.
Tôi đã cố gắng để nạp bằng tay từ Sharepoint2013, nó hoạt động tốt ở đó. Có điều gì thiếu ? Nhờ sự giúp đỡ ..