none
Getting a value from ListItem RRS feed

  • Question

  • I am trying to get this "Description" value out of a ListItemCollection (Sharepoint.Client) I've tried about everything I know to do but I cant get it!

    The Watch screen can see it, and I've copied the expression, but when attempting to use the same expression in my code i get null reference exception.

                For Each listItem As ListItem In WorkflowTasklistItemCollection
                    .Tables("WorkflowTasks").Rows.Add(
                                      DirectCast(listItem("WorkflowLink"), Microsoft.SharePoint.Client.FieldUrlValue).Description, 'Exception here
                                      listItem("ID"))
                Next


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Wednesday, August 15, 2018 3:05 PM

Answers

  • I worked it out, somewhere in the collection lived empty or null items, had to check the object before adding the row.
                For Each listItem As ListItem In WorkflowTasklistItemCollection
                    Dim WFLinkDesc As String = String.Empty
                    If listItem("WorkflowLink") IsNot Nothing Then
                        WFLinkDesc = DirectCast(listItem("WorkflowLink"), Microsoft.SharePoint.Client.FieldUrlValue).Description
                    End If
                    .Tables("WorkflowTasks").Rows.Add(
                                      WFLinkDesc,
                                      listItem("ID"))
                Next



    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    • Marked as answer by Gtripodi Wednesday, August 15, 2018 4:41 PM
    Wednesday, August 15, 2018 4:34 PM