0
我目前正在使用Office加載項來檢查內容控件的單詞文檔,並將採用這些內容控件的名稱和標記並進行其餘的調用SharePoint來檢查Mod日期。我目前正在加載標籤和標題出和問題,我的問題是,如果我發現國防部的日期不一樣,我希望能夠加載該特定的內容控制。獲取一次加載的特定內容控制Office-js
目前代碼
function loadContentControls() {
Word.run(function (context) {
var contentControlProperties = [];
var contentControls = context.document.contentControls;
context.load(contentControls, "id");
return context.sync().then(function() {
if (contentControls.items.length > 0) {
for (var x = 0; x < contentControls.items.length; x++) {
contentControls.items[x].load('title,' + "tag");
}
}
else {
$("#notificationBody").html("<h4>No Update Found</h4>");
messageBanner.showBanner();
messageBanner.toggleExpansion();
}
return context.sync().then(function (e) {
for (var x = 0; x < contentControls.items.length; x++) {
contentControlProperties.push({
Name: contentControls.items[x].title,
Moddate: contentControls.items[x].tag,
});
}
return context.sync().then(function() {
var url;
var unParsedDateTime;
var parsedDateTime;
for (var i = 0; i < contentControlProperties.length; i++) {
url = "https://tenant/sites/ContentCenter/_api/web/Lists/GetByTitle('kist')/items?select=Title,Title&$filter=Title eq '" + contentControlProperties[0].Name + "'";
authContext.acquireToken(config.endpoints.SharePoint, function (error, token) {
if (error || !token) {
console.log('error');
return;
}
else {
$.ajax({
type: "GET",
url: url,
headers: {
"Authorization": "Bearer " + token,
"accept": "application/json;odata=verbose"
},
success: function (data) {
unParsedDateTime = new Date(data.d.results[0].Modified);
parsedDateTime = unParsedDateTime.toLocaleDateString('en-US').concat(' ' + unParsedDateTime.getHours() + ':' + unParsedDateTime.getMinutes());
>> So if there is a date discrepancy I would like to grab that specific content control here
},
error: function (error) {
console.log("Fetching list from SharePoint failed.");
}
})
}
});
}
})
})
})
.catch(function (error) {
error.ErrorLocation = "Inserting Content To Doc";
error.ErrorCode = error.debugInfo.errorLocation;
error.ErrorMessage = "Could Not Insert Image";
error.Selection = selectedContents.Name;
ErrorHandler(error);
})
})
}