2013-06-09 7 views
2

в метаданных, управляемых sharepoint. Я нашел очень мало документации по управлению терминами с использованием javascript CSOM. Я мог бы создать таксономический термин непосредственно под установленным термином, но я хочу создать термин под другим термином в качестве дочернего элемента, например, в окне хранилища сроков.Создать таксономический подзаголовок с использованием CSOM и javascript

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()); 
}); 
} 

ответ

5

Для того, чтобы добавить термин под родительским срок, вам необходимо:

  • Идентификатор Срок хранения и соответствующий срок установлен
  • Родитель Term 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()); 
    });} 

 Смежные вопросы

  • Нет связанных вопросов^_^