How does WorkItem.Save() work?

Go To StackoverFlow.com

2

What gets saved with WorkItem.Save ? Everything that was changed/added/deleted, including new attachments that were added, etc?

I am trying to determine how it works internally. Let's say something fails like one item cannot be set or one attachment cannot be added for whatever reason, is there error thrown when Save is called or when you try to set the property in question?

If one of these items fails, do the rest of the operations still succeed or are there options such as "everything or nothing", etc.

Any guidance around this would be helpful.

2012-04-03 21:13
by user1060500
FYI this answers some of my questions http://msdn.microsoft.com/en-us/library/bb130323(v=vs.80).asp - user1060500 2012-04-03 21:22


3

A work item is an atomic entity. If you call save(), it will either update the work item with the changes, or it will fail. You cannot get into a state where some of the changes to the work item were saved and others were not.

When you set the fields on a work item, the work item is then evaluated for its validity. Work items have "rules" that are defined by the process template that must validate in order for the client to attempt a save. You can call WorkItem.IsValid() in order to determine whether the work item is in a valid state or not.

For more information on validity, you can call WorkItem.Validate() to get a list of invalid fields.

If you were to ignore the validity of the work item, and just call WorkItem.Save(), it will throw a ValidationException.

2012-04-03 21:23
by Edward Thomson