I've written some code in an attempt to keep a Content Editor Web Part in sync with a Wiki Pages Library.
This code executes and states that it's completed successfully without error. Checking the wiki page itself shows no updated content however. What am I doing wrong?
(This is SharePoint 2013 if that matters).
updateWiki: function () {
var tabContent2 = $("#mainTabstrip-2 .ms-rtestate-field").html();
HCE.Page.getItemsWithCaml("FAQwiki").then(
function (listItemCollection, clientContext) {
var listItemEnumerator = listItemCollection.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
clientContext.executeQueryAsync(
//success
Function.createDelegate(this,
function () {
console.log(oListItem.get_item("PageName"));
if (oListItem.get_item("PageName") == "FAQ") {
oListItem.set_item("WikiField", tabContent2);
clientContext.executeQueryAsync(
//success
Function.createDelegate(this, function () {
console.log("Wiki content update successful for FAQ.");
}),
//fail
Function.createDelegate(function (sender, e) {
console.log("error updating WikiField content for FAQ: " + e.get_message() + "\n" + e.get_stackTrace());
})
);