views:

151

answers:

1

Hi, Can you please let us know if it is possible retrieve user ID of the person who last modified a document using MOSS list web service? If yes, please let me know the column name.

A: 

Each item has a Modified property, as well as a Modified By field, which respectively have Modified and Editor as their Internal field names. SO yes you can view who modified a document last and when that modification was done.

The CAML for the ViewFields would be

<ViewFields>
  <FieldRef Name='Modified' />
  <FieldRef Name='Editor' />
</ViewFields>

So placing this in the MSDN example on the GetListItems documentation page woulbe become:

SrvRef.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlDocument xmlDoc = new System.Xml.XmlDocument();

XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
ndViewFields.InnerXml = "<FieldRef Name='Modified' /><FieldRef Name='Editor' />";
// maybe add a Where clause as well to retrieve specific items only
// XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
// ndQuery.InnerXml = "<Where><ADD PREDICATES HERE</Where>";

try
{

  XmlNode ndListItems = listService.GetListItems("LISTNAME", null, null, ndViewFields, null, null, null);
  // do something with the result
}
catch (System.Web.Services.Protocols.SoapException ex)
{
  MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
}
Colin
Thanks for providing the above explanation and sample code. I think the above fields return last modified person's name. We are looking if we can retrieve last modified person's user ID in SharePoint instead of name.Thanks.
stranger001
get the name first, then query the userinfo list, using the modified by name in the where, specify id in the viewfields
Colin

related questions