SharePoint Client Object Model Validate Specific Column is available in Library

To Check or Validate that specific column is available in Document Library use below code.

private bool ValidateDocumentLibraryColumn(string DocumentLibrary , string ListColumnName)
{
using (ClientContext clientContext = new ClientContext(SharepointSite))
{
try
{

Microsoft.SharePoint.Client.Web web = clientContext.Web;

ListCollection lists = web.Lists;

List lst = lists.GetByTitle(DocumentLibrary);

Field fld = lst.Fields.GetByInternalNameOrTitle(ListColumnName);

clientContext.Load(fld);

clientContext.ExecuteQuery();

return true;
}
catch (Exception exception)
{
ShowErrorMessage(exception.ToString());

return false;
}
}
}

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s