Question

I have a custom SharePoint 2010 SPfield of type SPFieldMultiColumn. The data in this column is stored in a delimited string, which is parsed and rendered in a readable format in most areas (list view, 'view properties' etc). The raw data looks like this (wording changed):

;#0;#LABEL1;#True;#GUID;#DESCRIPTION_OF_LABEL;#;#1;#LABEL2;#True;#GUID;#DESCRIPTION_OF_LABEL2;# ...

and so on. The descriptions are pretty long, making this string hundreds of characters long, and really ugly when not parsed out and rendered. The issue with this is that in certain parts of the system, we cannot control the rendering of the field. The most common issue we see is in datasheet view, where the raw data is displayed and just looks terrible, and makes datasheet nearly unusable for users. The data also shows up in alert emails and search results.

I was tasked with making this 'prettier' and my solution was to add a secondary, 'display' column, and to hide the 'data' column. When an item is updated or added, I have event receivers which transform and move the data into the display field, which looks nice in datasheet view and so on.

This all works great, except for the fact that it requires 2 Update() calls on each item that gets this metadata. One when the 'data' field is populated, and another when the event receiver copies the data into the display.

Our production (and QAS, but not test or development) farms utilize Remote Blob Storage (RBS), and our operations team has found that whenever this column (or I guess any column) is updated on an office document (doc, docx, etc) it causes a new blob in the file system. So as the solution is today, a new file uploaded will generate 2 blobs (one for the upload, one for the application of this metadata). With this new eventreceiver, we will now generate 3 blobs, which is unnacceptable to our operations team (we don't have 50% more disk space to support this).

'Fixing' RBS is out of the question - so I need to somehow update both of these columns at once, rather than updating one, which fires an event receiver to update the other.

Is there any way to update 2 custom SPFields with 1 call to Update()?

TL;DR: Custom solution with 2 custom SPFields - one updated through the 'edit' form, the other through an event receiver (second is completely reliant on the first for it's data). How can I update both without the use of an event receiver (with only one Update() call?)

Was it helpful?

Solution

It sounds like you're using the ItemUpdated event. If you used ItemUpdating I believe you could modify the AfterProperties instead of performing a second update.

This may be of use to you: NBSP: Event Receivers

OTHER TIPS

When you create a Lookup column, you can choose to show additional columns from your lookup list.

It looks like what you would want here is a list with your Label/Description, and then a lookup column to the Label column, and have the description as an additional field. I don't know if it would be perfectly clean in Data Sheet View though, but it would be an improvement.

Another potential solution to this sort of problem is a Calculated column, but from what I see of your scenario it doesn't fit.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top