Skip to main content

Knowledge Base

Go Search
Home > Support > Knowledge Base > Pages > 98281.aspx  

Use the Set List Item Data task 
Category: Bug 
Applies to: Kivati Studio 

This article describes how to use the Set List Item Data task to set data into SharePoint list items.

Details

The Set List Item Data task is used to set field data for list items stored in SharePoint lists.  This task is very powerful and can be used for a variety of situations.  This article contains information on how to use this task in several common scenarios as well of topics of interest related to this task.

Task Basics

The Set List Item Data task has a property named FieldData that contains a collection of fields to set values for.  Another task, Set List Item Data (Single Field), provides this same functionality without the collection for use with chained properties.  To set a field, add an item to the collection using the task designer.  There are three properties for each item in the collection:

  • Field.  The name of the field to set (see Addressing Fields, below).
  • Value.  The value to insert into the field.  This is always stored as a string and converted to the data type required automatically by SharePoint.
  • Encoded.  If true, the value is Base64-encoded.  If false, the value is a plain value.

Addressing Fields

SharePoint stores two names for each field - a display name, shown to users in the SharePoint user interface, and an internal name, used internally by applications.  You can choose to address fields in either of these two modes depending on your preferences.  You can also choose to let the Set List Item Data task automatically detect the names used for fields; this is the default and recommended setting.  To change the addressing mode, change the value of the FieldOpenType property to one of either Automatic, InternalName, or DisplayName.

Special Fields

Some fields in SharePoint have special meanings.  Some of these fields are shown below, specified by their display names:

  • Title.  Controls the title of the list item.
  • Content Type.  Controls the content type of the list item.  Change this value to change the content type.

Unsupported Fields

Some fields in SharePoint cannot be directly set through the object model.  To set these fields, direct access to the content database must be obtained.  Because this can void support agreements with Microsoft and possibly corrupt your data, this option is off by default.  If you set SetUnsupportedFields to true, you can set the following additional fields:

  • Author and Editor.  Use these fields to control the created and modified by user for a list item.  The data should be specified in the format "#;Username" where # is the user's ID number and username is the display name of the user.  For example, specify "3;John Doe" to set a field value to "John Doe" with an ID of 3.  You can get a user's ID using the Get User Properties task (in WSS security).
  • Created and Modified.  Use these fields to change the date and time the list item was created or modified.  Specify a date in your local time zone.

You can also set any field that is normally read-only using unsupported mode.  However, you do risk corrupting your content database, so make a backup prior to using this mode.

More Information

SharePoint's SDK contains a wealth of documentation on fields and list items which may be useful to you when using this task.  Consult the SharePoint SDK for additional information.

Last update: 5/1/2008 
Copyright 2000-2008 Kivati Software, LLC.
Home| Support| Terms of Use| Privacy| Legal