Share via


Data Manipulation Using Workflow Script

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Session.Item object can be used to return values from the current record of a table, or to set values in a table. You specify the name of the column for which you want to retrieve or set a value. When setting values, you must run a Session.Item.Updatebatch method to commit the update.

If you change a value and then want to compare the new value with the original value, you can use the Session.OriginalItem object. However, you must have the MakeDeletedRowsAvailable property of the workflow process set to True to persist modified values. For more information, see The Workflow Engine Model.

Session.Item is used in the Finding a Manager in the User Directory example to specify the name of the field that contains the SAMAccountName.

Following are three examples that use the Session object:

Getting a Value

Function GetValue(strFieldName)
'strFieldName is the name of the column that contains the data you are returning
   GetValue = session.item(strFieldName)
End Function

Setting a Value

Sub SetValue(strFieldName)
'strFieldName is the name of the column that contains the data to which you are appending the date
   Session.item(strFieldName) = session.item(strFieldName)& ' ' &  date
   Sesssion.item.updatebatch
End sub

Checking a Value

Function CheckValue(strFieldName)
'strFieldName is the name of the column that contains the data you are comparing
  If session.item(strFieldName) <> session.originalitem(strFieldName) then
      'Do something
  End if
End function

See Also

Scripting Workflow Events for SQL Server | Scripting Events in the Workflow Designer for SQL Server | When to Use Which Event | Error Handling for Workflow Script | Testing and Debugging in the Workflow Designer for SQL Server | Retrieval of User Information by Workflow Script | Lookup of Role Membership Based On SAMAccountName