SharePoint - CSOM Validations - Getting View Columns

时间:2019-03-19 14:43:19

标签: .net vb.net sharepoint csom

I have a loop which lists the through sites and then the document libraries and performs certain validations in CSOM. One of things requested was to add a CheckedOutUser to all libraries. I encounter a weird scenario when I try to load the fields. Right now, I'm just trying to gather a list of the default views that don't meet the criteria.

It bombs out at the line for calling the ExecuteQuery on the fields object.

Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null.

I already have a null check in there.

                ' Get Fields for View - Report of Libraries Without Checked Out User
                Dim defaultView = innerList.DefaultView
                If Not defaultView Is Nothing Then
                    client.Load(defaultView)
                    client.ExecuteQuery()

                    'client.Load(defaultView.ViewFields)
                    Dim fields = innerList.DefaultView.ViewFields

                    If Not fields Is Nothing Then
                        client.Load(fields)
                        client.ExecuteQuery()

                        '    If Not fields.Contains("CheckoutUser") Then
                        '        m_DefaultViewsWithoutCheckedOutUser.Add(innerList.DefaultView.ServerRelativeUrl)
                        '    End If
                    End If
                End If

0 个答案:

没有答案