When using Get List Info / For Each List Item, is there a way to retrieve all the versions of each list item? And a related question, how do I access Sharepoint columns that Sharepoint lists as having a type of “Multiple lines of text”?
For example, I have a list which contains a column named V3Comments which Sharepoint says has a type of “Multiple lines of text”. When a list item is updated, this column gets a new “version” that will be blank if the user is not specifically updating this column. I want to retrieve all the “versions” of this column so that I can build a unified record with the value for this column being the latest version of it that has a value.
At the moment, I’m getting a Dictionary item (string, object) from each ListItem and trying to iterate through the Dictionary item to get the type/value of each column. This works fine for strings and integers, but seems to fail on columns of other types like “Lookup”, “Data and Time”, and “Multiple lines of text”.
For example, trying to get the type or value from these list item columns returns an error of “Object reference not set to an instance of an object.”
For example doing Assigns:
columnType = currentItem.Value.GetType.ToString
columnValue = currentItem.Value.ToString
Hi @Bill_Richardson
To retrieve all versions of each list item in SharePoint using UiPath, you can use the SharePoint REST API to make a request to the item’s versions endpoint. Here’s how you can do it:
Use the “Get List Items” activity to get the list items from your SharePoint list.
Use a “For Each” loop to iterate through each item in the list.
Within the loop, use the “Make Request” activity to make a GET request to the item’s versions endpoint. The URL for this endpoint should be in the format: https://<your-site-url>/_api/web/lists/getbytitle('<your-list-title>')/items(<your-item-id>)/versions.
Parse the JSON response from the “Make Request” activity to extract the version information for each item. The version information should be in an array called “value” within the response JSON. You can use another “For Each” loop to iterate through the version information for each item.
Within the nested loop, you can access the version information for each column by using the column name as the key to access the value in the JSON.
To access columns in SharePoint that are of the “Multiple lines of text” type, you can use the same approach as above. The column value will be returned as a JSON object, which you can parse to extract the text value.
Here’s an example of how you can extract the value of a “Multiple lines of text” column:
Use the “Get List Items” activity to get the list items from your SharePoint list.
Use a “For Each” loop to iterate through each item in the list.
Within the loop, use the “Get List Item” activity to get the item’s details, including the “Multiple lines of text” column.
The value of the “Multiple lines of text” column will be returned as a JSON object, which you can parse to extract the text value. To do this, you can use the “Deserialize JSON” activity to convert the JSON object to a dictionary. Then, you can use the dictionary key (which should be the name of your column) to access the value of the column.