My new blog present here.

Featured Post

Insights into Sitecore Search: A Definitive Introduction

A key component of digital experience management is effective information retrieval. A simplified approach is required for websites, applications, and platforms containing a lot of material so that consumers can easily get the data they require. This need is met by Sitecore, a well-known name in the field of digital experience platforms (DXPs), which provides powerful and comprehensive search functionality. We will travel into the realm of Sitecore Search in this article, learning about its capabilities, architecture , and the enormous value it offers both developers and end users. Introduction to Sitecore Search    A headless content discovery platform powered by AI , Sitecore Search enables you to build predictive and custom search experiences across various content sources. To extract and index you

SPServices:Update item in SharePoint List or Document Library using SPServices jQuery library in SharePoint

In my previous article, How to create folder inside SharePoint List or Document Library using SPServices jQuery library in SharePoint, I already explained about $().SPServices.UpdateListItems operation to access the listing of folder.

For example, in SharePoint online site, we need to update item in SharePoint List or Document library on the basis of key field when user click on button.

To implement above requirement, we can not use the SharePoint Server Side code, so we need to utilize the Client Side Scripting – JSOM/Call to SharePoint REST API using JQuery/Use of SPServices JQuery Library.

Now, I am going to explain how to update item in SharePoint List or Document Library using SPServices jQuery library in SharePoint. SPServices JavaScript Library ($().SPServices) provides function called UpdateListItems to update content in the SharePoint list.
  • Update item the SharePoint Document Library or List using $().SPServices.UpdateListItems operation with valuepairs option:
       [pre class="brush:jscript" ] $().SPServices({ operation: "UpdateListItems", async: false, batchCmd: "Update", listName: "AmitKumar_TestList", ID: 1, valuepairs: [["Title","Amit Kumar"]], completefunc: function (xData, Status) { console.log('List items has been updated'); } }); [/pre]
     In the above code block, we are not using updates attributes of "UpdateListItems" operation,
    instead using valuepairs attribute to define the columns which needs to be updated on the basis of ID of element/row.
   We can define more than one columns in valuepairs attribute, it will serve as an array of columns:
valuepairs: [["Title", "Amit Kumar"], ["Technologies", ".NET, SharePoint, AngularJS"]]
  • Update item in SharePoint Document Library or List using $().SPServices.UpdateListItems operation with CAML query:
[pre class="brush:jscript" ] var camlQuery = '' + '' + 'Amit Kumar' + '.NET, SharePoint, AngularJS' + '1' + '' + ''; $().SPServices({ operation: "UpdateListItems", async: false, listName: "AmitKumar_TestList", updates: camlQuery , completefunc: function(xData, Status) { console.log('List items has been updated'); } }); [/pre]

In the above code block, we are not using batchCmd/ID attributes of "UpdateListItems" operation, instead using updates attribute to define the columns which needs to be updated based on ID of element/row. The default for the batchCmd option is 'Update'


More articles on SPServices:
What is SPServices
How to access List Data using SPServices jQuery library in SharePoint
How to access list of folder name from SharePoint List or Document Library using SPServices jQuery library in SharePoint
How to create/add folder in SharePoint List or Document Library using SPServices jQuery library in SharePoint
Update item in SharePoint List or Document Library using SPServices jQuery library in SharePoint

Comments

Popular posts from this blog

Sitecore GraphQL Queries

Sitecore Experience Edge GraphQL Queries

Configuring Sitecore Next.js Headless SXA Multisite App in a Sitecore Container