2

sharepoint で管理されたメタデータでは、javascript CSOM を使用した用語の管理に関するドキュメントはほとんど見つかりませんでした。用語セットの直下に分類用語を作成できますが、用語ストア ウィンドウのように子として別の用語の下に用語を作成したいと考えています。

function createTerm(){
//Current Context
var context = SP.ClientContext.get_current();
//Current Taxonomy Session
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
//Term Stores
var termStores = taxSession.get_termStores();
//Term Store under which to create the term.
var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");
//Term Set under which to create the term.
var termSet = termStore.getTermSet("b49f64b3-4722-4336-9a5c-56c326b344d4");
//Name of the term, LCID and a new GUID for the term.
var newTerm = termSet.createTerm("India", 1033, "b49f64b3-4722-4336-9a5c-56c326b344a9");
//newTerm.set_isAvailableForTagging(true);
context.load(newTerm);
context.executeQueryAsync(function(){
alert("Term Created: " + newTerm.get_name());
 },function(sender,args){
console.log(args.get_message());
});
}
4

1 に答える 1

5

親用語の下に用語を追加するには、次のものが必要です。

  • 用語ストア ID と関連する用語セット
  • 親用語 ID (新しい子用語が追加される)

コード:

 function execOperation()
 {
    //Current Context
    var context = SP.ClientContext.get_current();

    //Current Taxonomy Session
    var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);

    //Term Stores
    var termStores = taxSession.get_termStores();

    //Term Store under which to create the term.
    var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");

    //Term Set under which to create the term.
    var termSet = termStore.getTermSet("b49f64b3-4722-4336-9a5c-56c326b344d4");


    //get the parent term ID, say it's "cf46hujkl-3344-4336-9a5c-56c326b344d4"
    var parentTerm = termSet.getTerm("cf46hujkl-3344-4336-9a5c-56c326b344d4");

    //create new child term under the parent term
    var newTerm = parentTerm.createTerm("SharePoint Rocks", 1033, newGuid.toString());

    context.load(newTerm);
    context.executeQueryAsync(function(){
    alert("Term Created: " + newTerm.get_name());
     },function(sender,args){
    console.log(args.get_message());
    });}
于 2013-06-10T07:59:53.963 に答える