Spservices getlistitems managed metadata column

297 Views Asked by At

I have a regular custom list with all sorts of data but the one that's not working with the spservices getlistitems is the managed metadata field.

I am getting undefined when I tried to use ows_documentname .

Any suggestions are greatly appreciated

3

There are 3 best solutions below

0
Jerry On BEST ANSWER

Please see the capture about the metadata field value format, it will like "ID;#Label": enter image description here

Please split this like:

$(this).attr("ows_metadata").split(";#")[1]
0
Gautam Sheth On

The value of the managed metadata field will be returned in the ID;#Value format.

So, you need to split it using javascript split function as below. Here, the internal name of managed metadata column is Test:

$(this).attr("ows_Test").split(";#")[1]

Modify the code as per your column internal name.

The full code that i used is:

$().SPServices({
        operation: "GetListItems",
        async: true,
        listName: "Documents",
        CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query>",
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function () {
                console.log($(this).attr("ows_Test").split(";#")[1]);
            });
        }
});
0
venkatram sunkara On

Thank you for your help.

I was doing the same but I had the wrong internal name from site template site.

Your solutions are correct.