Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Variables used in this code:
- string url_site = "http://prod_01/human-resources/property/";
- string _user = "shpfarm";
- string _password = "******";
- // CSOM Authentication:
- ClientContext clientContext = new ClientContext(url_site);
- CredentialCache myCache = new CredentialCache();
- myCache.Add(new Uri(url_site), "NTLM", new NetworkCredential(_user, _password));
- clientContext.Credentials = myCache;
- try
- {
- string HolidayDate = DateTime.Today.ToString("yyyy-MM-dd");
- string holiday_list_URL = "http://prod_01/human-resources/property/Lists/Holidays/AllItems.aspx";
- List lst_Holiday = clientContext.Web.GetList(holiday_list_URL);
- clientContext.Load(lst_Holiday);
- Console.WriteLine("List called succesfully");
- // Query: Get if current date is a holiday:
- CamlQuery cmlQueryHoliday = new CamlQuery();
- cmlQueryHoliday.ViewXml = string.Format(@"<View>
- <Query>
- <Where>
- <Eq>
- <FieldRef Name='HolidayDate' />
- <Value IncludeTimeValue='TRUE' Type='DateTime'>{0}</Value>
- </Eq>
- </Where>
- </Query>
- </View>", HolidayDate);
- ListItemCollection colItems = lst_Holiday.GetItems(cmlQueryHoliday);
- clientContext.Load(colItems);
- clientContext.ExecuteQuery();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error calling list (using URL): " + ex.ToString());
- }
- in Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
- in Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder)
- in Microsoft.SharePoint.SPWeb.GetList(String strUrl)
- in Microsoft.SharePoint.ServerStub.SPWebServerStub.InvokeMethod(Object target, String methodName, XmlNodeList xmlargs, ProxyContext proxyContext, Boolean& isVoid)
- in Microsoft.SharePoint.Client.ServerStub.InvokeMethodWithMonitoredScope(Object target, String methodName, XmlNodeList args, ProxyContext proxyContext, Boolean& isVoid)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.InvokeMethod(Object obj, String methodName, XmlNodeList xmlargs, Boolean& isVoid)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPath(XmlElement xe)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPathId(String objectPathId)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessInstantiateObjectPath(XmlElement xe)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElement xe)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)
- in Microsoft.SharePoint.Client.ClientMethodsProcessor.Process()
Add Comment
Please, Sign In to add comment