none
store list item value from sharepoint into variables RRS feed

  • Question

  • 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();

    Monday, May 13, 2019 10:06 PM

All replies