Han de Monnink
Guest
|
Posted:
Tue Jan 18, 2005 4:37 pm Post subject:
How to use the GetListItems |
|
|
I'am trying to find the ID of an item in a documentlibrary, by making a
WebService call GetListItems on the Lists webservice entry.
The code Is identical to what is specified in the SDK the only thing I
changed is the query;
listService.Credentials=
System.Net.CredentialCache.DefaultCredentials;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode
(XmlNodeType.Element,"Query","");
XmlNode ndViewFields = xmlDoc.CreateNode
(XmlNodeType.Element,"ViewFields","");
XmlNode ndQueryOptions = xmlDoc.CreateNode
(XmlNodeType.Element,"QueryOptions","");
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>
FALSE</IncludeMandatoryColumns>" +
"<DateInUtc>TRUE</DateInUtc>";
ndViewFields.InnerXml = "<FieldRef Name='ID'/>
<FieldRef Name='Title' />";
ndQuery.InnerXml = "<Where><Eq><FieldRef
Name='Title'/>" +
"<Value type='Text'>testdoc</Value></Eq>" +
"</Where>";
try
{
XmlNode ndListItems = listService.GetListItems
("doclib2", null, ndQuery,
ndViewFields, null, ndQueryOptions);
//MessageBox.Show(ndListItems.OuterXml);
}
.................................
I'am trying to find the ID of the Item which is called 'testdoc' in a
document library called 'doclib2' but for some reason this always results
in an error, Can't find the reason for this ...
Any body any idea
Han |
|
Jim McCusker
Guest
|
Posted:
Thu Jan 20, 2005 7:23 pm Post subject:
RE: How to use the GetListItems |
|
|
I don't believe the ID can be queried this way. When you look at an SPItem
object you can reference the field data using SPItem[fieldName] but the ID
can only be returned by using SPItem.ID.
"Han de Monnink" wrote:
| Quote: | I'am trying to find the ID of an item in a documentlibrary, by making a
WebService call GetListItems on the Lists webservice entry.
The code Is identical to what is specified in the SDK the only thing I
changed is the query;
listService.Credentials=
System.Net.CredentialCache.DefaultCredentials;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode
(XmlNodeType.Element,"Query","");
XmlNode ndViewFields = xmlDoc.CreateNode
(XmlNodeType.Element,"ViewFields","");
XmlNode ndQueryOptions = xmlDoc.CreateNode
(XmlNodeType.Element,"QueryOptions","");
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns
FALSE</IncludeMandatoryColumns>" +
"<DateInUtc>TRUE</DateInUtc>";
ndViewFields.InnerXml = "<FieldRef Name='ID'/
FieldRef Name='Title' />";
ndQuery.InnerXml = "<Where><Eq><FieldRef
Name='Title'/>" +
"<Value type='Text'>testdoc</Value></Eq>" +
"</Where>";
try
{
XmlNode ndListItems = listService.GetListItems
("doclib2", null, ndQuery,
ndViewFields, null, ndQueryOptions);
//MessageBox.Show(ndListItems.OuterXml);
}
.................................
I'am trying to find the ID of the Item which is called 'testdoc' in a
document library called 'doclib2' but for some reason this always results
in an error, Can't find the reason for this ...
Any body any idea
Han
|
|
|