RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically
Hey Paul, The commented code was setting the Content Type properties in a hashtable and applying that on file upload, but no that wasnt working. I suspect the Office 2003 doc was then promoting its properties to SharePoint and overwriting this setting. My code then goes processes a CSV (for original property data for each item from the old DMS), XML (for data mapping conversions of these old values to new SharePoint property values), and a huge switch statement that sets the new property value for different types of SharePoint columns, updating the item after ever property value had been set. I found that if I then re-set the content type setting after all of this done, the content type setting stuck (I assume this is occurring after the document had promoted its properties). Like I said, probably not the most efficient thing in the world, but its working now :D Cheers, Nigel Date: Wed, 15 May 2013 15:57:23 +1000 Subject: Re: Issues Uploading Office 2003 docs to SP 2010 Programmatically From: web.ad...@syd.catholic.edu.au To: ozmoss@ozmoss.com Nigel, In my experience you need to set the properties before adding the file, which your commented code was already doing. Did that not work for you? Regards, Paul On 15 May 2013 13:55, Nigel Witherdin nigel_wither...@hotmail.com wrote: Ok - have come up with a kludge of a fix. I upload the file, get the item, set the content type, set all the metadata then get the item again and set the content type again. This time the content type setting seems to stick. Yay - only took a few additional round trips to the database to re-get the item, re-set the content typemaybe not so yay after all Oh well, at least it works now ;) From: nigel_wither...@hotmail.com To: ozmoss@ozmoss.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 02:15:18 + I thought setting the ParserEnabled to false would prevent any property promotion/demotion. See - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.parserenabled.aspx and http://sharepointserver-2007.blogspot.com.au/2012/04/sharepoint-spweb-property-parserenabled.html But unfortunately, Office 2003 docs are still ruining my day From: is...@exd.com.au To: ozmoss@ozmoss.com; conrad.grob...@gmail.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 01:05:55 + Promotion of properties is my daily nemesis these days. I share your pain. In the past I used to overcome this by uploading using the frontpage RPC – which allows you to set the promoted properties in XML before sending it to the site. However, it is cumbersome to use, and the object model should do what it is told! Ishai Sagi | Solutions Architect 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | @ishaisagi | MVP Profile From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Nigel Witherdin Sent: Wednesday, 15 May 2013 10:37 AM To: OzMoss; Conrad Grobler Subject: Issues Uploading Office 2003 docs to SP 2010 Programmatically Hi All, We are using an in-house developed tool to upload files from old DMS into SharePoint 2010, and are finding we are having issues with Office 2003 docs. The tool uploads the file, sets content type, and then set metadata (as read from a CSV). This all works fine for PDFs, DOCXs, etc. but it does not work with DOCs. Frustratingly, it doesn't report any errors, and the logging info looks just fine for these files. Instead of being set to the specified content type, they are always set to the default content type of the library, and do not have the metadata values set as expected. The code being used to upload the file and set the content type (both ways it has been tried) is: targetList.ParentWeb.ParserEnabled = false; targetList.ParentWeb.Update(); //Hashtable ht = new Hashtable(); //ht.Add(ContentTypeId, targetCt.Id.ToString()); //ht.Add(ContentType, targetCt.Name); //SPFile file = targetFolder.Files.Add(filename, fs, ht, true); //file.Update(); SPFile file = targetFolder.Files.Add(filename, fs, true); file.Update(); file.ParentFolder.Update(); file.Item[SPBuiltInFieldId.ContentTypeId] = targetCt.Id; file.Item[SPBuiltInFieldId.ContentType] = targetCt.Name; file.Item.UpdateOverwriteVersion(); targetList.ParentWeb.ParserEnabled = true; targetList.ParentWeb.Update(); I have done some googling on the issue, and can see that other people have had different issues with SP 2010 and Office 2003, but nothing that definitively states there is an issue loading these files programmatically (and setting CT
Re: Issues Uploading Office 2003 docs to SP 2010 Programmatically
Well that's all that matters in the long run. :) Regards, Paul Noone SharePoint Farm Admin/Developer Infrastructure Team CEO Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: paul.no...@syd.catholic.edu.au w: http://www.ceosyd.catholic.edu.au/ On 15 May 2013 16:26, Nigel Witherdin nigel_wither...@hotmail.com wrote: Hey Paul, The commented code was setting the Content Type properties in a hashtable and applying that on file upload, but no that wasnt working. I suspect the Office 2003 doc was then promoting its properties to SharePoint and overwriting this setting. My code then goes processes a CSV (for original property data for each item from the old DMS), XML (for data mapping conversions of these old values to new SharePoint property values), and a huge switch statement that sets the new property value for different types of SharePoint columns, updating the item after ever property value had been set. I found that if I then re-set the content type setting after all of this done, the content type setting stuck (I assume this is occurring after the document had promoted its properties). Like I said, probably not the most efficient thing in the world, but its working now :D Cheers, Nigel -- Date: Wed, 15 May 2013 15:57:23 +1000 Subject: Re: Issues Uploading Office 2003 docs to SP 2010 Programmatically From: web.ad...@syd.catholic.edu.au To: ozmoss@ozmoss.com Nigel, In my experience you need to set the properties before adding the file, which your commented code was already doing. Did that not work for you? Regards, Paul On 15 May 2013 13:55, Nigel Witherdin nigel_wither...@hotmail.com wrote: Ok - have come up with a kludge of a fix. I upload the file, get the item, set the content type, set all the metadata then get the item again and set the content type again. This time the content type setting seems to stick. Yay - only took a few additional round trips to the database to re-get the item, re-set the content typemaybe not so yay after all Oh well, at least it works now ;) -- From: nigel_wither...@hotmail.com To: ozmoss@ozmoss.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 02:15:18 + I thought setting the ParserEnabled to false would prevent any property promotion/demotion. See - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.parserenabled.aspx and http://sharepointserver-2007.blogspot.com.au/2012/04/sharepoint-spweb-property-parserenabled.html But unfortunately, Office 2003 docs are still ruining my day -- From: is...@exd.com.au To: ozmoss@ozmoss.com; conrad.grob...@gmail.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 01:05:55 + Promotion of properties is my daily nemesis these days. I share your pain. In the past I used to overcome this by uploading using the frontpage RPC – which allows you to set the promoted properties in XML before sending it to the site. However, it is cumbersome to use, and the object model should do what it is told! [image: Description: Description: C:\Users\Brian\Pictures\EXD Logos\Extelligent logo no text.jpg]*Ishai Sagi* | Solutions Architect 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | @ishaisagihttp://twitter.com/ishaisagi | MVP Profile https://mvp.support.microsoft.com/profile/Ishai *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On Behalf Of * Nigel Witherdin *Sent:* Wednesday, 15 May 2013 10:37 AM *To:* OzMoss; Conrad Grobler *Subject:* Issues Uploading Office 2003 docs to SP 2010 Programmatically Hi All, We are using an in-house developed tool to upload files from old DMS into SharePoint 2010, and are finding we are having issues with Office 2003 docs. The tool uploads the file, sets content type, and then set metadata (as read from a CSV). This all works fine for PDFs, DOCXs, etc. but it does not work with DOCs. Frustratingly, it doesn't report any errors, and the logging info looks just fine for these files. Instead of being set to the specified content type, they are always set to the default content type of the library, and do not have the metadata values set as expected. The code being used to upload the file and set the content type (both ways it has been tried) is: targetList.ParentWeb.ParserEnabled = false; targetList.ParentWeb.Update(); //Hashtable ht = new Hashtable(); //ht.Add(ContentTypeId, targetCt.Id.ToString()); //ht.Add(ContentType, targetCt.Name); //SPFile file = targetFolder.Files.Add(filename, fs, ht, true); //file.Update(); SPFile file = targetFolder.Files.Add(filename, fs, true); file.Update();
Re: Issues Uploading Office 2003 docs to SP 2010 Programmatically
From memory, the only issue I ran into was with a custom Document Information panel. I wound up cleansing the Office document metadata with a tool and setting the list's template URL property to null. On 16 May 2013 08:06, Web Admin web.ad...@syd.catholic.edu.au wrote: Well that's all that matters in the long run. :) Regards, Paul Noone SharePoint Farm Admin/Developer Infrastructure Team CEO Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: paul.no...@syd.catholic.edu.au w: http://www.ceosyd.catholic.edu.au/ On 15 May 2013 16:26, Nigel Witherdin nigel_wither...@hotmail.com wrote: Hey Paul, The commented code was setting the Content Type properties in a hashtable and applying that on file upload, but no that wasnt working. I suspect the Office 2003 doc was then promoting its properties to SharePoint and overwriting this setting. My code then goes processes a CSV (for original property data for each item from the old DMS), XML (for data mapping conversions of these old values to new SharePoint property values), and a huge switch statement that sets the new property value for different types of SharePoint columns, updating the item after ever property value had been set. I found that if I then re-set the content type setting after all of this done, the content type setting stuck (I assume this is occurring after the document had promoted its properties). Like I said, probably not the most efficient thing in the world, but its working now :D Cheers, Nigel -- Date: Wed, 15 May 2013 15:57:23 +1000 Subject: Re: Issues Uploading Office 2003 docs to SP 2010 Programmatically From: web.ad...@syd.catholic.edu.au To: ozmoss@ozmoss.com Nigel, In my experience you need to set the properties before adding the file, which your commented code was already doing. Did that not work for you? Regards, Paul On 15 May 2013 13:55, Nigel Witherdin nigel_wither...@hotmail.comwrote: Ok - have come up with a kludge of a fix. I upload the file, get the item, set the content type, set all the metadata then get the item again and set the content type again. This time the content type setting seems to stick. Yay - only took a few additional round trips to the database to re-get the item, re-set the content typemaybe not so yay after all Oh well, at least it works now ;) -- From: nigel_wither...@hotmail.com To: ozmoss@ozmoss.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 02:15:18 + I thought setting the ParserEnabled to false would prevent any property promotion/demotion. See - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.parserenabled.aspx and http://sharepointserver-2007.blogspot.com.au/2012/04/sharepoint-spweb-property-parserenabled.html But unfortunately, Office 2003 docs are still ruining my day -- From: is...@exd.com.au To: ozmoss@ozmoss.com; conrad.grob...@gmail.com Subject: RE: Issues Uploading Office 2003 docs to SP 2010 Programmatically Date: Wed, 15 May 2013 01:05:55 + Promotion of properties is my daily nemesis these days. I share your pain. In the past I used to overcome this by uploading using the frontpage RPC – which allows you to set the promoted properties in XML before sending it to the site. However, it is cumbersome to use, and the object model should do what it is told! [image: Description: Description: C:\Users\Brian\Pictures\EXD Logos\Extelligent logo no text.jpg]*Ishai Sagi* | Solutions Architect 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | @ishaisagihttp://twitter.com/ishaisagi | MVP Profile https://mvp.support.microsoft.com/profile/Ishai *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On Behalf Of * Nigel Witherdin *Sent:* Wednesday, 15 May 2013 10:37 AM *To:* OzMoss; Conrad Grobler *Subject:* Issues Uploading Office 2003 docs to SP 2010 Programmatically Hi All, We are using an in-house developed tool to upload files from old DMS into SharePoint 2010, and are finding we are having issues with Office 2003 docs. The tool uploads the file, sets content type, and then set metadata (as read from a CSV). This all works fine for PDFs, DOCXs, etc. but it does not work with DOCs. Frustratingly, it doesn't report any errors, and the logging info looks just fine for these files. Instead of being set to the specified content type, they are always set to the default content type of the library, and do not have the metadata values set as expected. The code being used to upload the file and set the content type (both ways it has been tried) is: targetList.ParentWeb.ParserEnabled = false; targetList.ParentWeb.Update(); //Hashtable ht = new Hashtable(); //ht.Add(ContentTypeId, targetCt.Id.ToString());