gpt4 book ai didi

javascript - 指定的参数超出了有效值的范围。参数名称: index

转载 作者:行者123 更新时间:2023-12-03 11:06:17 25 4
gpt4 key购买 nike

我有以下 JavaScript 代码,它必须从共享点托管元数据存储加载术语集。代码一直工作正常,直到周一,突然停止工作,出现标题上的错误。

我仅使用 console.log 更改了executequeryasync 的内容,但仍然有错误。

我已经逐行调试了 execGetTermIds,并且没有任何行抛出异常

function GetTermsDataFromTaxonomy(){
//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();
//Name of the Term Store from which to get the Terms.
var termStore = termStores.getByName("Taxonomy_kl5tZjInn7STsFTzIE7n3Q==");
//GUID of Term Set from which to get the Terms.
var termSet = termStore.getTermSet("31da4bc1-6429-499a-9d5e-be5e18b13c87");
var terms = termSet.getAllTerms();
var list;
var p = execGetTermIDs();
p.done(function(result) {

context.load(terms);

context.executeQueryAsync(function(){
console.log("hola");
},
function(sender,args){
console.log(args.get_message());
});
});
p.fail(function(result) {
// result is a string because that is what we passed to reject()!
var error = result;
console.log(error);
});

}

function sortTermsFromTree (tree) {
if (tree.children.length && tree.term.get_customSortOrder) {
var sortOrder = null;

if (tree.term.get_customSortOrder()) {
sortOrder = tree.term.get_customSortOrder();
}

// If not null, the custom sort order is a string of GUIDs, delimited by a :
if (sortOrder) {
sortOrder = sortOrder.split(':');

tree.children.sort(function (a, b) {
var indexA = sortOrder.indexOf(a.guid);
var indexB = sortOrder.indexOf(b.guid);

if (indexA > indexB) {
return 1;
} else if (indexA < indexB) {
return -1;
}

return 0;
});
}
// If null, terms are just sorted alphabetically
else {
tree.children.sort(function (a, b) {
if (a.title > b.title) {
return 1;
} else if (a.title < b.title) {
return -1;
}

return 0;
});
}
}

for (var i = 0; i < tree.children.length; i++) {
tree.children[i] = sortTermsFromTree(tree.children[i]);
}

return tree;
}

function execGetTermIDs(){
var d = $.Deferred();
var q = "<View><Query><Where></Where></Query></View>";
var context = new SP.ClientContext(siteUrl);
var oList = context.get_web().get_lists().getByTitle('TaxonomyHiddenList');
var camlQuery = SP.CamlQuery.createAllItemsQuery();
var collTermListItem = oList.getItems(camlQuery);
context.load(collTermListItem);
var o = {d: d, collTermListItem:collTermListItem};
context.executeQueryAsync(
Function.createDelegate(o, getTermIDsComplete),
Function.createDelegate(o, failCallback)
);
return d.promise();
}

function getTermIDsComplete()
{
var listItemEnumerator = this.collTermListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
termIDs[oListItem.get_fieldValues().Title] = oListItem.get_id();
}
this.d.resolve(termIDs);
}

function failCallback() {
this.d.reject("something bad happened");
}

最佳答案

天啊,我发现了这个错误,但我找不到对此的解释,希望 Microsoft 的有人可以告诉我。

这一行:

 var termStore = termStores.getByName("Taxonomy_kl5tZjInn7STsFTzIE7n3Q==");   

我们注意到名称现在不同了,它有不同的 guid,但我们作为客户无法更改该名称,所以唯一的原因是 Microsoft 为我们更改了它,因为它在周一工作。

更新:我将该行更改为:

termStore = session.getDefaultSiteCollectionTermStore();

避免将来发生这种情况。

关于javascript - 指定的参数超出了有效值的范围。参数名称: index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27842010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com