labs.steveottenad.com

Getting “ows_MetaInfo” with SPServices

If you use the SPServices library (link) to grab info from lists, you’ve more than likely ran into an instance where the information you need is contained in a gnarly string inside the “ows_MetaInfo” attribute. There is a very easy solution to change this large string into its appropriate attributes, making the information contained in it super easy to access. Just include CAMLViewFields: “<ViewFields Properties=’True’ />” in your initial SPServices call, and you’ll now have access to all that information as attributes instead of a string

Example

$().SPServices({
        operation: "GetListItems",
	async: false,
	listName: "YOURLIBRARY",
	CAMLViewFields: "<ViewFields Properties='True' />",
	completefunc: function (xData, Status) {
	 		$(xData.responseXML).find("[nodeName='z:row']").each(function(i) {
					var description = $(this).attr('ows_Description');
			});			
	}	
});

5 Comments

  1. Steve:

    This is a great tip, and I’ve added it to the SPServices documentation for GetListItems. I’ve never seen this documented anywhere, so it’s a real find. If you come up with other tips like this, please let me know.

    Thanks,
    M.

  2. Stephany Henrique says:

    Parabéns, eu não estava conseguindo retornar o link de uma imagem contida em uma lista. Com este post consegui retornar.

    Grato,

  3. Jimmy says:

    Hi, this doesn’t seem to work for me.. i’m using

    “”,

  4. […] The custom metadata fields were required for the K2 process, however these fields were not returned as separate attributes when using the GetListItems method of the lists web service.  They only appeared in the cryptic ows_MetaInfo field, which probably could be parsed out using some regular expressions, however I discovered a much simpler solution thanks to this post. […]

Leave a Reply