Solved

SharePoint 2010 Document Library Document Properties

Posted on 2012-03-23
13
862 Views
Last Modified: 2013-06-04
I have a VSTO word add in that uploads  documents to a document library on a SharePoint 2010 site.  The document gets uploaded and the custom document properties which mirror the document library view columns indeed show the custom properties as uploaded.  All well and good.

However,  when I click the document on the list and launch word to edit the document,  making changes to the document custom properties and uploading.  These updated custom properties are not reflected on that document item.

I can see the properties that I modified from within Word/File/Info, but not on the updated list item.
0
Comment
Question by:hbash
  • 7
  • 6
13 Comments
 
LVL 51

Expert Comment

by:tedbilly
ID: 37760970
So the document meta properties are duplicated in the list columns?  If yes, then SharePoint will not synchronize the meta properties in the document with the list columns without additional programming.
0
 
LVL 1

Author Comment

by:hbash
ID: 37761971
It does pick up the values on the initial add though?  They don't do update? That's a bummer.  So now I need to write some event listener code.  Do you have any snippets or links describing the objects I'll need to manipulate for this then?  

Seems to me if they do add the meta data values from the document on add only, this is an error in design.
0
 
LVL 1

Author Comment

by:hbash
ID: 37762050
Here is what I see.  I upload the file the first time and the document set properties show up in the SharePoint list with their current values from the document meta properties.  On subsequent uploads the changed custom column values are not reflected in the list for this uploaded document update.

However,  if I open the list via windows explorer,  I can change the documents meta data in word and then drag the modified file onto the windows explorer I had openned and the updates meta data values appear in the SharePoint list.
0
 
LVL 1

Author Comment

by:hbash
ID: 37762796
I have started looking at build an event receiver for handling the updating of an item's meta data.  

Here are the hurdles:
Not generic.  It seems to require a list by name in the setup and so this would be a problem for a site where users create lists that need this behavior.  I wonder if instead of listening for an event on a list you could instead listen for an event on a content type and you make the list based on that content type as the only requirement for list creation by users.

I tried modifying properties in a receiver and the update failed.  Here is the code and the error:


public override void ItemUpdating(SPItemEventProperties properties)
       {
           try
           {
               if (properties.ListTitle == "MyList")
               {
                   properties.ListItem["Status"] = "Modified In Rcvr Server Code";
                   properties.ListItem["MyListName"] = "MyList";
                   properties.ListItem["MyNumber"] = "9";
                   properties.ListItem.Update();
               }
           }
           catch (Exception ex)
           {
               string msg = ex.Message.ToString();
           }

           finally
           {
               base.ItemUpdating(properties);
           }
       }


ERROR FOLLOWS:

"The file \"http://mybox/sites/mysandbox/MyList/Doc2.docx\" is locked for shared use by mybox\\administrator."
0
 
LVL 51

Expert Comment

by:tedbilly
ID: 37763169
You are on the right path.  If you want a generic event it has to be a feature that deploys a content type.  The feature would then be installed per site, site collection or even web application as required.
0
 
LVL 1

Author Comment

by:hbash
ID: 37793108
I am able to use a listener to get to the item property and change it.  However,  when I do changes the property,  it fires that event again.  Not a good thing.  I suppose I could introduce some semaphore(s) but there must be a better event to catch the item.  I have been looking at the updated and updating events.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 51

Expert Comment

by:tedbilly
ID: 37793656
Yes, you need to use the Updated or Updating event.
0
 
LVL 1

Author Comment

by:hbash
ID: 37797275
The problem though is that when you update a property of the list item within the handler, the handler raises the event as well.
0
 
LVL 51

Expert Comment

by:tedbilly
ID: 37799403
0
 
LVL 1

Author Comment

by:hbash
ID: 37800589
There are some snippets there that sound interesting. Unfortunately,  it's not clear to me exactly where theses snippets go.  For me,  a tiny complete example works better than disconnected snippets whose placement is sometimes not obvious.

Reading that link,  you will find people saying it's great stuff and also where do I put the snippets.  I fall somewhere near that group.  If you can show a more complete (tiny) complete usage of the snippets, this would be much more useful to me.
0
 
LVL 51

Accepted Solution

by:
tedbilly earned 500 total points
ID: 37804629
0
 
LVL 1

Author Comment

by:hbash
ID: 37892912
Yes I have.
0
 
LVL 51

Expert Comment

by:tedbilly
ID: 37895500
Well as far as I can see all the details for the implementation are on that original solution.  I don't see anything that is missing.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now