'SP.XmlWriter' is null or not an object

Nov 13, 2013 at 9:03 PM
Hi there. I'm trying to use this and am getting JS error 'SP.XmlWriter' is null or not an object on line 627 charater 13 of your camljs.js file. I have referenced your file and am using the first example from the homepage. Since this is your code, it will be easier if I just post this instead of trying to debug it myself.

I also have JQuery 1.8.3 and SPServices 2013.01 referenced on the page.

Thoughts?
Coordinator
Nov 13, 2013 at 10:29 PM
Edited Nov 13, 2013 at 10:33 PM
Hi,

SP.XmlWriter is defined in SP.Runtime.js.
  1. Please check if this file is loaded on your page. E.g. in IE, F12 -> Scripts tab -> try finding sp.runtime.js among the loaded scripts.
  2. If sp.runtime.js is there, please ensure that you code is executed after SP.Runtime.js is loaded. This can be achieved via SP.SOD.executeFunc:
SP.SOD.executeFunc('sp.runtime.js', 'SP.XmlWriter', function() {
  //your code here
});
Another option is that you're using SP2007 that doesn't have sp.runtime.js at all. In this case you have to copy SP.XmlWriter and Sys.StringBuilder from the SP2010 and include them for example into the camljs.js or as a separate file. If this is the case, I can help creating such a file, I guess it will be useful for guys who have to support SP2007 installations.
Nov 14, 2013 at 7:29 PM
Edited Nov 14, 2013 at 7:29 PM
Thanks for the response. We were executing our code outside of a document.ready so the core JS files weren't loaded yet. We got one of your exmaples to work; however, we can't get our custom code to work. We are trying to build CAML for a lookup field and their isn't much documentation on this site about using this for Lookups

Below is an example of what we have that isn't working. I'm sure it is WAY off, but this is what we have based on this site and the camljs.js file.
camlBuilder.Where().LookupField("LookupName").ValueAsText.EqualTo("1").Or().LookupField("LookupName").ValueAsText.EqualTo("2").ToString()
We get error "Object doesn't support this property or method".
Coordinator
Nov 15, 2013 at 6:58 PM
ValueAsText is method

try this:
camlBuilder.Where().LookupField("LookupName").ValueAsText().EqualTo("1").Or().LookupField("LookupName").ValueAsText().EqualTo("2").ToString()