Skip to main content

I don't see Content Type in the list of fields of a Document Library in the Get Documents' Metadata option of the SharePoint Documents Event Wizard.


This seems like a pretty critical attribute that you'd want to know about a document.  Is this a known feature request?  Any suggested workarounds?

I just played with it a little bit and could not get the Content Type field either. I think you are going to have to run the wizzard then break into the code and query it manually. I am thinking that should work

I'm not sure that this is possible within the code generated by the wizard.  Can you post an example of how to add custom code to the code generated by a wizard?


It looks like the code is just generic code that loops through the XML data and makes calls to the K2 dlls.  The code always remains the same, no matter what selections you make in the Wizard.  As an example, I looked at the code behind 2 different SharePoint Documents Events Wizards.  I copied each set of code into notepad and ran WinDiff on them.  They were identical, with the exception of 2 lines that contained the host context (pointers back to the instance of the event). 


When you go into the codebehind an event you can modify it and it will be saved just don't "Update Design Templates"


With regards to the metadata, I have done some looking and cant for the life of me find a way to query content type from a specific item.


There is a code sample on http://msdn2.microsoft.com/en-us/library/lists.lists.getlistitems.aspx


You will have to loop through the returned XML to matchup the document name in each instance.  This is stored in the documentName variable. in our function


For example The GetListItems (http://<MOSSURL>/_vti_bin/lists.asmx?op=GetListItems) Web service returns the content type, among other things. This would have to be written in the GetDocumentMetaData_ExecuteCode(object sender, EventArgs e) function or at least called from there.


<?xml version="1.0" standalone="yes"?>
<Documents>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="1">
<z:row ows_MetaInfo="1;#Subject:SW| Keywords:SW| _Status:EW| PublishingExpirationDate:EW| PublishingStartDate:EW| vti_parserversion:SR|12.0.0.6219 vti_modifiedby:SR|DENALLIXmike vti_title:SW| _Author:SW|mike _Category:EW| ContentType:LW|Document ContentTypeId:SW|0x0101005FF81A005535144290B244EC4B3ED501 _Comments:SW| vti_author:SR|DENALLIXmike " ows__ModerationStatus="0" ows__Level="1" ows_Last_x0020_Modified="1;#2008-01-07T22:22:36Z" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{743005D6-0E56-4701-8B31-5E1E3BCF3B15}" ows_FSObjType="1;#0" ows_Created_x0020_Date="1;#2008-01-07T22:22:36Z" ows_ProgId="1;#" ows_FileLeafRef="1;#sdfdsfsdf.docx" ows_Modified="2008-01-07T22:22:36Z" ows_FileRef="1;#Documents/sdfdsfsdf.docx" ows_DocIcon="docx" ows_Editor="18;#Mike" />
</rs:data>
</listitems>
</Documents>


Remember if you are adding this to the Document event itself NEVER right-click on the event and select “Update Design Templates” or that will erase all custom code.  You may want to do this in a seperate server event, but do what you feel comforatable with


 


Reply