0

I currently do have a working method in VB and proven through usage on other lists.

Below will be my code

Public Sub getWiki(ctx As ClientContext)

    Dim WaterIce As SP.List = ctx.Web.Lists.GetByTitle("Water & Ice WIKI")
    Dim camlQuery As New CamlQuery

    camlQuery.ViewXml = "<Query><Where><And><Contains><FieldRef Name='FileLeafRef' /><Value Type='File'>home</Value></Contains><IsNotNull><FieldRef Name='WikiField' /></IsNotNull></And></Where></Query>"

    Dim collatedListItem As ListItemCollection = WaterIce.GetItems(camlQuery)

    ctx.Load(collatedListItem)
    ctx.ExecuteQuery()

    Dim oListItem As ListItem

    For Each oListItem In collatedListItem

        htmlString = oListItem.FieldValues("WikiField").ToString()
        'MsgBox(htmlString)

        If htmlString <> "" Or htmlString IsNot Nothing Then

            Exit For

        End If
    Next

    WaterIceInnerDiv.InnerHtml = htmlString

End Sub

I did a debug by myself, and I will think it is the title which is causing the problem. If I try with a different list name, for example ctx.Web.Lists.GetByTitle("Water WIKI"), it will run fine and able to extract the information. I suspect it is the & in the title, and the error occurs at this line htmlString = oListItem.FieldValues("WikiField").ToString() with null exception.

  • You can get list by its id or try to get list by the name which is set in the url (when you are in the list). It could be that the name is resolved like FieldNames with special chars (e.g. x200) – Chris K Apr 24 '17 at 12:37
0

Not sure this will work, but try throwing a STSHtmlEncode at it: ctx.Web.Lists.GetByTitle(STSHtmlEncode("Water & Ice WIKI"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.