Question

I'm trying to add HTML content into a Multiline Text field (Enhaced Rich Text).

When I set field to pure string, the field is updated:

    $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "LIST",
        valuepairs: [["scTabela", "OLA"]],
        completefunc: function (xData, Status) {          

        }
    });

But when I set field to html, no error occurs, but the field is not updated. Field stay blank.

    $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "LIST",
        valuepairs: [["scTabela", "<p>Olá</p>"]],
        completefunc: function (xData, Status) {          

        }
    });

I don't know what I'm doing wrong. Anyone can help me?

Was it helpful?

Solution

Use below:

var value = SP.Utilities.HttpUtility.htmlEncode(html);

$().SPServices({
    operation: "UpdateListItems",
    async: false,
    batchCmd: "New",
    listName: "LIST",
    valuepairs: [["scTabela", value]],
    completefunc: function (xData, Status) {          

    }
}); 

OTHER TIPS

Create one div in your html and take input from user. Div will allow user to input rich content.

Then after write code below:

var divContent = $('#divInputText').html();

$().SPServices({
    operation: "UpdateListItems",
    async: false,
    batchCmd: "New",
    listName: "LIST",
    valuepairs: [["scTabela", divContent]],
    completefunc: function (xData, Status) {          

    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top