Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

As per the title above, I have a list that stores IT support requests. I need a sequence number that matches with the item ID and I want to add this sequence number to the Title of the request.

I know that we can add an item added event receiver and get it done. Since I am already adding the request item via a Visual webpart thought it might be nice to have all the functionalities under one shell.

Any suggestions?

share|improve this question
    
The OOTB column ID on list items is not enough I guess? –  Robert Lindgren Apr 17 '13 at 13:33
    
@RobertLindgren Nope! I want the users to have a service request ID... thats a lil meaningful! –  Muhammedh May 19 '13 at 9:26

1 Answer 1

up vote 3 down vote accepted

First add the List Item so its Id is generated, than get the item again... Update its Title field and concat Id column with it.. Pseudo-code below:

ListItem newItem = lstObject.Items.Add();
newItem["Field"] = "something";

newItem.Update();

newItem = lstObject.Items.GetItemById(newItem.Id);
newItem["Title"] = "YourText" + newItem.Id.ToString();
newItem.Update();

If you don't want the other update to create version than you can use UpdateOverwriteVersion() instead of Update() function!

share|improve this answer
    
Thanks :)! It worked! –  Muhammedh Apr 18 '13 at 7:24
    
or SystemUpdate() method. –  Muhammedh Jun 2 '13 at 13:03
    
Small catch to this solution is if you have set up an alert on this list for send when new items are added you will not see the new title in the email. Just a friendly note :)! –  Muhammedh Feb 25 at 7:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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