Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

store values into variables from list item based on string match on another column using c#

$
0
0

Hi,

I want to store the values of a list item from sharepoint list into 3 different variables in my script.I have gone this far as in below but not sure how i can get to filter the list item on one column based on string match and store the value of the another column corresponding the match.I dont want to use foreach loop as we dont have to loop through the list.

Example of data in sharepoint list attached.I want to store the Email column values into 3 variables in the script by searching the Type column to match a string- if (Type =Master-US,get the value of Email and store it in a variable) and similarly for the other 2 items.

var site = (string)Dts.Variables["$Package::Site"].Value;
       
            var Recipients_Shp = (string)Dts.Variables["$Package::List"].Value;
            List DistList = context.Web.Lists.GetById(new Guid(Recipients_Shp));
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View>"
         + "<Query>"
         + "<Where><BeginsWith><FieldRef Name='ABCD002d' /><Value Type='Text'>Master</Value></BeginsWith></Where>"
         + "</Query>"
         + "</View>";
            ListItemCollection collListItem = DistList.GetItems(camlQuery);

            context.Load(collListItem);
            context.ExecuteQuery();

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>