Created
December 17, 2016 00:29
-
-
Save andyhuey/c5a25484c3fb1efcf1b4a3eaf388795b to your computer and use it in GitHub Desktop.
a bit of SharePoint CSOM code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool doesVendorRecExist(string companyCode, string vendorNum, | |
List vendorList, ClientContext cc) | |
{ | |
CamlQuery spq = new CamlQuery(); | |
spq.ViewXml = string.Format(@" | |
<View><Query> | |
<Where><And> | |
<Eq><FieldRef Name='VendorNo' /><Value Type='Text'>{0}</Value></Eq> | |
<Eq><FieldRef Name='CompanyName' /><Value Type='Text'>{1}</Value></Eq> | |
</And></Where> | |
</Query></View>", vendorNum, companyCode); | |
ListItemCollection myItems = vendorList.GetItems(spq); | |
cc.Load(myItems); | |
try | |
{ | |
cc.ExecuteQuery(); | |
} | |
catch (Microsoft.SharePoint.Client.ServerException ex) | |
{ | |
Console.WriteLine("Error in doesVendorRecExist({0},{1}): {2}", companyCode, vendorNum, ex.Message); | |
Environment.Exit(-1); | |
} | |
return (myItems.Count > 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment