To check whether the list item contains the attachment programmatically or using CSOM. Get the list item collection and then check for the attachment column.
List listEvent = web.Lists.GetByTitle(listName);
clientContext.Load(listEvent, L => L.Id);
CamlQuery camlQuery2 = new CamlQuery();
camlQuery2.ViewXml = "<View><Query></View></Query>";
ListItemCollection item_Coll = listEventSource.GetItems(camlQuery2);
clientContext.Load(item_Coll);
clientContext.ExecuteQuery();
foreach (ListItem oLstItem in item_Coll)
{
bool attachmentPresent = Convert.ToBoolean(oLstItem["Attachments"]);
if (attachmentPresent)
{
Console.WriteLine("Item is present");
}
}
List listEvent = web.Lists.GetByTitle(listName);
clientContext.Load(listEvent, L => L.Id);
CamlQuery camlQuery2 = new CamlQuery();
camlQuery2.ViewXml = "<View><Query></View></Query>";
ListItemCollection item_Coll = listEventSource.GetItems(camlQuery2);
clientContext.Load(item_Coll);
clientContext.ExecuteQuery();
foreach (ListItem oLstItem in item_Coll)
{
bool attachmentPresent = Convert.ToBoolean(oLstItem["Attachments"]);
if (attachmentPresent)
{
Console.WriteLine("Item is present");
}
}
Happy Coding !!!!!
Comments
Post a Comment