Hey Fellas,
Well there are many times we need to call the SharePoint list for data in our CSOM applications,
Here below i have a Sharepoint List named "Settings" which contains the desired data.
I am using CSOM to get that data and returning it on the call of my function.
public static String
GetSettings(ClientContext context, String Key)
{
List settingsList =
context.Web.Lists.GetByTitle("Settings");
String value = null;
var query = new CamlQuery() {
ViewXml = "" + Key +
" "
};
ListItemCollection items =
settingsList.GetItems(query);
context.Load(items);
context.ExecuteQuery();
try
{
foreach (ListItem listItem in
items)
{
value =
listItem["Value"].ToString();
}
}
catch (Exception ex)
{
Logger.Info(" ");
}
return value;
}
Let me know if this works for you.
Thanks people!
No comments:
Post a Comment