I'm loading a SharePoint list using the client service object model (SharePoint 2013 on-premise). I'm using the following code:
private void buttonRefreshOrders_Click(object sender, RoutedEventArgs e)
{
using (var ctx = new ClientContext("http://sharepoint/ci/resources"))
{
var list = ctx.Web.Lists.GetByTitle("Resource Order Form Content");
var query = new CamlQuery
{
ViewXml =
@"<Where><Or><Eq><FieldRef Name=""Status""></FieldRef><Value Type=""Text"">Approved</Value></Eq><IsNotNull><FieldRef Name=""Status"" /></FieldRef></IsNotNull></Or></Where>"
};
var collListItem = list.GetItems(query);
ctx.Load(collListItem);
ctx.ExecuteQuery();
if (collListItem.Count == 0)
{
MessageBox.Show(
"No orders are currently within the queue.",
"Information Center",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
else
{
MessageBox.Show("Success!");
foreach (var item in collListItem)
{
MessageBox.Show(item["Status"].ToString());
}
}
}
}
I receive the exception:
An unhandled exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException' occurred in Microsoft.SharePoint.Client.dll
Typically I believe this happens when the name being referenced in the following line doesn't match what's in SharePoint's backend:
MessageBox.Show(item["Status"].ToString());
However I don't understand how that's the case here as I've used this exact same naming within my CamlQuery. I've also used SP Caml Query Helper 2013
and the field names appear to be correct.
How can I find the correct field names that I should be referencing?