Среда:
- SharePoint 2010
- jquery-1.12.3.min
- jquery.SPServices-2014.02.min
Попытка использовать метод SPSerivces для чтения списка SP в javascript.
При просмотре окончательного вывода у меня есть следующая информация (ключ XX имеет значение YY), которая не относится к данным, которые я пытаюсьполучить.Этот список даже не соответствует возврату, который подробно описан в онлайн-документации .
key state has value function(){return c}
key always has value function(){return e.done(arguments).fail(arguments),this}
key then has value function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()}
key promise has value function(a){return null!=a?n.extend(a,d):d}
key pipe has value function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()}
key done has value function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){n.each(b,function(b,c){n.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==n.type(c)&&d(c)})}(arguments),c&&!b&&i()),this}
key fail has value function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){n.each(b,function(b,c){n.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==n.type(c)&&d(c)})}(arguments),c&&!b&&i()),this}
key progress has value function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){n.each(b,function(b,c){n.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==n.type(c)&&d(c)})}(arguments),c&&!b&&i()),this}
Что я делаю не так с этим звонком?Как мне сохранить список SP в переменной сценария java?
Ниже приведен вызов SPSerivce и фрагмент данных:
function getListUsingSPSerivces(){
//SPServices Example
//The Web Service method we are calling, to read list items we use 'GetListItems'
var method = "GetListItems"; //IGNORE
//The display name of the list we are reading data from
var url = "BASE_URL/sp/XXYY/_vti_bin/listdata.svc/"
var list = "RFCExtract";
//Acquire GUID
//var listGUID = $().SPServices.SPListNameFromUrl();
//console.log (listGUID);
//list = listGUID;
var fieldsToRead = "<ViewFields>" +
"<FieldRef Name='RFC_x0020_Number' />" +
"<FieldRef Name='Title' />" +
"<FieldRef Name='Status' />" +
"<FieldRef Name='Date' />" +
"<FieldRef Name='Class' />" +
"</ViewFields>";
//this is that wonderful CAML query I was talking about earlier. This simple query returns
//ALL rows by saying "give me all the rows where the ID field is not equal to 0". I then
//tell the query to sort the rows by the Title field. FYI: a blank query ALSO returns
//all rows, but I like to use the below query because it helps me know that I MEANT to
//return all the rows and didn't just forget to write a query :)
var query = "<Query>" +
"<Where>" +
"<Neq>" +
"<FieldRef Name='RFC_x0020_Number'/><Value Type='Number'>0</Value>" +
"</Neq>" +
"</Where>" +
"<OrderBy>" +
"<FieldRef Name='RFC_x0020_Number'/>" +
"</OrderBy>" +
"</Query>";
//Here is our SPServices Call where we pass in the variables that we set above
console.log("SPSerivces example");
//console.log(method);
console.log(url);
console.log(list);
var rfcList = $().SPServices.SPGetListItemsJson({
webURL: url,
async: false, //if you set this to true, you may get faster performance, but your order may not be accurate.
listName: list,
CAMLViewFields: fieldsToRead,
CAMLQuery: query,
debug: true
});
for (var key in rfcList) {
console.log("key " + key + " has value " + rfcList[key]);
}
};
Источник страницы списка, который я читаю, с двумя записямивыглядит следующим образом:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="<**BASE_URL**>/_vti_bin/listdata.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">RFCExtract</title>
<id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract</id>
<updated>2018-11-29T12:43:44Z</updated>
<link rel="self" title="RFCExtract" href="RFCExtract" />
<entry m:etag="W/"1"">
<id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(1)</id>
<title type="text">Test</title>
<updated>2018-11-28T15:07:57-05:00</updated>
<author>
<name />
</author>
<link rel="edit" title="RFCExtractItem" href="RFCExtract(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(1)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(1)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(1)/Attachments" />
<category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
<d:Title>Test</d:Title>
<d:Class m:type="Edm.Double">1</d:Class>
<d:Status>Closed</d:Status>
<d:Date m:type="Edm.DateTime">2010-11-01T00:00:00</d:Date>
<d:RFCNumber m:type="Edm.Double">1</d:RFCNumber>
<d:Id m:type="Edm.Int32">1</d:Id>
<d:ContentType>Item</d:ContentType>
<d:Modified m:type="Edm.DateTime">2018-11-28T15:07:57</d:Modified>
<d:Created m:type="Edm.DateTime">2018-11-28T15:07:57</d:Created>
<d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
</m:properties>
</content>
</entry>
<entry m:etag="W/"1"">
<id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(2)</id>
<title type="text">Test Record 2</title>
<updated>2018-11-29T07:42:19-05:00</updated>
<author>
<name />
</author>
<link rel="edit" title="RFCExtractItem" href="RFCExtract(2)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(2)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(2)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(2)/Attachments" />
<category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
<d:Title>Test Record 2</d:Title>
<d:Class m:type="Edm.Double">2</d:Class>
<d:Status>Pending</d:Status>
<d:Date m:type="Edm.DateTime">2018-11-02T00:00:00</d:Date>
<d:RFCNumber m:type="Edm.Double">2</d:RFCNumber>
<d:Id m:type="Edm.Int32">2</d:Id>
<d:ContentType>Item</d:ContentType>
<d:Modified m:type="Edm.DateTime">2018-11-29T07:42:19</d:Modified>
<d:Created m:type="Edm.DateTime">2018-11-29T07:42:19</d:Created>
<d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
</m:properties>
</content>
</entry>
</feed>