Solved

SharePoint 2010 Document Library Document Properties

Posted on 2012-03-23
13
864 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:Howard Bash
  • 7
  • 6
13 Comments
 
LVL 51

Expert Comment

by:Ted Bouskill
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:Howard Bash
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:Howard Bash
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:Howard Bash
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:Ted Bouskill
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:Howard Bash
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 51

Expert Comment

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

Author Comment

by:Howard Bash
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:Ted Bouskill
ID: 37799403
0
 
LVL 1

Author Comment

by:Howard Bash
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:
Ted Bouskill earned 500 total points
ID: 37804629
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 37892912
Yes I have.
0
 
LVL 51

Expert Comment

by:Ted Bouskill
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

920 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

14 Experts available now in Live!

Get 1:1 Help Now