Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SP Object Model update row in list

  Asked By: Kevin    Date: Apr 14    Category: Sharepoint    Views: 2878

I've gotten the SP object model to update a specific row in a SP list. I want to
be able to update the row that activated the workflow. Here is the way I am
updating now, and it updates the 6th item in the list. I know why it updated
that row, just want it to update the correct row!

SPList selectedList = web.Lists["listName"];
SPListItem oListItem = selectedList.Items[5];
oListItem["fieldName"] = 25;



15 Answers Found

Answer #1    Answered By: Renae Key     Answered On: Apr 14

I'm trying very hard to find a question here...

Answer #2    Answered By: Irma Leon     Answered On: Apr 14

How do I get it to update  the row  that activated the workflow?

Answer #3    Answered By: Trevor Davis     Answered On: Apr 14

I think we need a bigger picture. Are you in an event handler? Which row  are you
updating versus which row are you hoping to update? Are you really trying to
update the 6th item? 5th? What...?

Answer #4    Answered By: Spiru Kelly     Answered On: Apr 14

This code is running in a custom activity that has been added to a workflow  in
SPD. I need to update  the row  that was just created, and in turn activated the

Answer #5    Answered By: Antoine Barker     Answered On: Apr 14

SPListItem oListItem = selectedList.Items[5];
item 5, 0 based array, 6th in our 1 based mind :)
he needs to replace that 5 with something like workflow.selected (no clue what
so ever as to what it really is)
but thats the question anyways

Answer #6    Answered By: Yasmin Bernard     Answered On: Apr 14

What about "Workflow item  id?" Create a list  item ID variable and stuff it
with the Workflow Item ID of any of the list items that are created from the
original list item.

Answer #7    Answered By: Javier Hawkins     Answered On: Apr 14

Maybe I need to explain some more. I have an InfoPath form that posts one
row/record to a SP2007 list  (doc lib actually). When the form posts to the
list, I want to run a workflow. I need to be able to update  a column in that row
depending on the value of other columns in that row.

Does that help?

Answer #8    Answered By: Mark Davis     Answered On: Apr 14

I must be misunderstanding...can you post more info?

Answer #9    Answered By: Tianna Hendrix     Answered On: Apr 14

Yes, you are not understanding. I am building a custom action to use in SPD. I
need to dynamically check fields, increment a counter, then post the counter
value back into another list  field.

Answer #10    Answered By: Jacklyn Burnett     Answered On: Apr 14

I have no experience with SPD custom activities...

Answer #11    Answered By: Diego Paul     Answered On: Apr 14

Wouldn't it be simpler/easier/better to do all of this in InfoPath itself
before posting to the list?

Answer #12    Answered By: Roop Kapoor     Answered On: Apr 14

I tried that, but couldn't get it all to work together.

Answer #13    Answered By: Shanita Smith     Answered On: Apr 14

Looks like I can use SPContext.Current to get the listItem that kicked off the
workflow. Now to figure out the syntax!

Answer #14    Answered By: Leilani Cooley     Answered On: Apr 14

Found this thread on a forum. Thought it might have some pertinent stuff.


Answer #15    Answered By: Allyson Burgess     Answered On: Apr 14

I can currently do everything I need to do in SPD. For example
I have a list  with 50 fields or so. I can go through them and the pseudocode for
each field looks like this.

if field_name = 1

'increment score
set wf variable to currentitem:score
increment wf variable by 1
set currentitem:score = wf variable

'increment counter
set wf variable to currentitem:counter
increment wf variable by 1
set currentitem:counter = wf variable

else field_name=0

'increment counter
set wf variable to currentitem:counter
increment wf variable by 1
set currentitem:counter = wf variable

I want to be able to do something like this, just to save time

if field_name = 1

MyCustom activity to increment score and counter

else field_name = 0

MyCustom activity to increment counter

Or better yet a custom action that iterates through the fields and then sets the
score and counter at the end! That would be the best solution.

Didn't find what you were looking for? Find more on SP Object Model update row in list Or get search suggestion and latest updates.