I'm very new to sharepoint and well to development...And I could use a little help !

I have a document library wich contains a multiple choice field (drop down with 3 choices), I've added 3 columns containing buttons. When a user click on a button, the value of the choice field is to be updated.

I know it's very simple but what is the best way to proceed? Could you provide me code snippet?

Thanks in advance !

  • 1
    Can you more clarify your task? I don't understand what's the need to update SharePoint choice field with buttons. – Alex Boev Mar 7 '12 at 9:23
  • Of course, basically the library contains mails and the multiple choice field indicates 3 states : not read, in progress and processed. The employee should be able by clicking on the button to indicate wich state he's at. – Pandorum Mar 7 '12 at 9:42
  • Did you add your buttons in SharePoint designer to list view webpart? – Alex Boev Mar 7 '12 at 10:13
  • yes, there are basic html buttons. – Pandorum Mar 7 '12 at 10:18
  • So you want to update automatically the choice field int he item where the button is clicked? But i don't understand the idea to allow the user to mark the items as read in that way because only one value can be saved per item and the second user will see the value saved by the first user. Is it desirable behaviour? – Alex Boev Mar 7 '12 at 10:47

So if I understand the task right and if we don't touch Visual Studio the solution will require the following steps:

  1. create an event handler in javascript for the button and get the target item id in it
  2. update the item via client object model (How to: Create, Update, and Delete List Items Using JavaScript)
  3. refresh the current list view web part to reflect changes.

UPDATE: If you want to go the C# path and do the work on the server side there's one well known way. To do the same you need:

  1. still create an event handler to your button
  2. create a custom application page with no UI - it will receive the update parameters via query string - and implement the update logic there. You need to redirect to that page from your handler and send as params the target item id, the desired update values and the url to return
  3. after the update item in your custom page do redirect back to the list view page and it will contain updated data of course.
  • Ok guys, thank you for your answers. Javascript is ok but I'm curious though, how would I proceed in C#? – Pandorum Mar 7 '12 at 13:24
  • @Pandorum See the update. – Alex Boev Mar 7 '12 at 14:23

Completely sidestepping your question, but you can set up Choice columns to show up as a group of radio buttons instead of a dropdown, that would take care of the edit form.

If you want to display those buttons in the list views and update the corresponding line's item, it could be done but it depends if you are using SP2007 or 2010?

However as Alex pointed out, those values will be per-user. If you really want user-specific values, you would need to maintain a second, separate list with read flags per item/per user, and keeping both lists in sync (deleting flags when mails get deleted) will add a good level of complexity unless again you are on SP2010 (which can enforce relationships with lookup fields)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.