Question

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?

Was it helpful?

Solution

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!

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