0

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

1 Answer 1

0

I figured out I was missing this line:

oListItem.update(); 

after:

oListItem.set_item("WikiField", tabContent2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.