CSOM in SharePoint

We have to refer the Client side DLL firstly
using sp = Microsoft.SharePoint.Client;

Creating sample JSON
PriceValuesJSON = @"[
                                                            {
                                                            ""Title"": ""SN"",
                                                            ""value"": 41.4
                                                            },
                                                            {
                                                            ""Title"": ""GN"",
                                                            ""value"": 109
                                                            }
                                                        ]";


Loop the values:
List<PriceValue_Item> PriceValuesList = JsonConvert.DeserializeObject<List<PriceValue_Item>>(PriceValuesJSON);
                                foreach (PriceValue_Item obj in PriceValuesList)
                                {
                                    createItemSharePointList_PriceValue(obj.Title, obj.value, filterSheetID);
                                }


public void createItemSharePointList_PriceValue(string Title, double value, int filterSheetID)
        {
            sp.ClientContext clientContext = new sp.ClientContext("siteURL");
            sp.List oList = clientContext.Web.Lists.GetByTitle("MyPrice");
            sp.ListItemCreationInformation itemCreateInfo = new sp.ListItemCreationInformation();
            sp.ListItem oListItem = oList.AddItem(itemCreateInfo);
            oListItem["Title"] = Title.ToString();
            oListItem["value"] = value;
            oListItem["ExcelInfo"] = filterSheetID;
            oListItem.Update();
            clientContext.ExecuteQuery();
        }



Comments

Popular posts from this blog

Powerapps overcome 2000 item limit from any datasource

PowerApps multiselect cascading dropdown and save an item to SharePoint List

Multi select cascading dropdown in Power Apps