Bulk delete SharePoint List items using CSOM

SharePoint CSOM enables us to delete bulk list items using browser console. Scenario-1:  We have a list of records to be deleted from a SharePoint list and we do not want to delete record one by one. Scenario-2:  We want to delete the list and list already had cross the threshold limit and not allowing to delete list until records reaches under the threshold limit. Following script demonstrates the steps to achieve the same Step-1:  Navigate to SharePoint site where list is present. Step-2: Open Inspect Element by clicking F12 in any browser. Open console tab. Step-3: Copy and Paste following code in console, Insert the list name (wherever ‘ListName’ is mentioned) and run the command. // ————————————— var clientContext; var website; var oList; var cnt = 0; // Make sure the SharePoint script file ‘sp.js’ is loaded before your code runs. SP.SOD.executeFunc(‘sp.js’, ‘SP.ClientContext’, sharePointReady); // Create an instance of the current context. function sharePointReady() { clientContext = SP.ClientContext.get_current(); website = clientContext.get_web(); oList = website.get_lists().getByTitle(‘ListName’); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml(‘1000’); this.collListItem = oList.getItems(camlQuery); clientContext.load(website); clientContext.load(collListItem, ‘Include(Id)’); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));… Read More

Read More

To set custom sub site icon in a custom master page.

I.e. For Sub Site – A: . For Sub Site – B: Below is the approach followed from me: Added below entry in master page but it was always resulting in wrong URL (404 URL not found) and referring to Site Collection URL (It was needed to refer sub site URL) <asp:Image runat=”server” id=”idMainSubSiteImageLink” CssClass=”subSiteIconData” ImageUrl=”../../SiteAssets/banner.png”></asp:Image> 2    I have used trick to resolve correct URL by following steps below: -Added entry of View All Site Contents from SharePoint, It’s NavigateUrl part gets converted to href with correct sub site URL. <SharePoint:SPLinkButton id=”idNavLinkViewAll1123″ CssClass=”subSiteIcon”  runat=”server” NavigateUrl=”~site/SiteAssets/banner.png” Text=””/> -Added below JavaScript to apply correct URL to Image link mentioned above and made SPLink hidden <script type=”text/javascript”>_spBodyOnLoadFunctionNames.push(“setImageSrc”);function setImageSrc() { var tempImageSrc = document.getElementById(“ctl00_idNavLinkViewAll1123”).getAttribute(“href”); document.getElementById(“ctl00_idMainSubSiteImageLink”). setAttribute(“src”,tempImageSrc); } </script> <style type=”text/css”> .subSiteIcon {display:none;} </style> – Now, it automatically applies proper image as per sub site user is navigating on.

Read More

Responsive GridView for Mobile Phone, Tablet and Desktop display in ASP.Net

In order to make the GridView responsive,You can use Footable jQuery plugin which is compatible with Bootstrap design. To use Footable jQuery include the following code inside the form tag- <link href=”https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css”         rel=”stylesheet” type=”text/css” />     <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script>     <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js”></script>     <script type=”text/javascript”>         $(function () {             $(‘[id*=GridView1]’).footable();         });     </script>   The HTML Markup consists of an ASP.Net GridView. You have to apply the CSS class footable to the GridView.     <asp:GridView ID=”GridView1″ CssClass=”footable” runat=”server” AutoGenerateColumns=”false”         Style=”max-width: 500px”>         <Columns>             <asp:BoundField DataField=”Id” HeaderText=”Id” />             <asp:BoundField DataField=”Name” HeaderText=”Name” />             <asp:BoundField DataField=”Company” HeaderText=”Company” />             <asp:BoundField DataField=”Age” HeaderText=”Age” />         </Columns>     </asp:GridView> You will need to import the following C# namespaces. using System.Data; Imports System.Data;   Binding the Grid View            protected void… Read More

Read More

JavaScript To Split The Words or Concatenated Word

<html> <body> First Word:-Hello<br/> Second Word:-world!<br/> <button onclick=”myFunction()”>Click To Split</button><br/> <pre>Concatenation:-<p id=”orgi”></p><br/> First Word:<p id=”demo”></p> Second Word:<p id=”demo1″></p> <script> function myFunction() { var str1 = “Hello”; var str2 = “world!”; var res = str1+”$|$”+str2; document.getElementById(“orgi”).innerHTML = res; var res1 = res.split(“$|$”)[0]; var res2 = res.split(“$|$”)[1]; document.getElementById(“demo”).innerHTML = res1; document.getElementById(“demo1”).innerHTML = res2; } </script> </body> </html> Snapshot:-     ——————————————————  

Read More

jQuery Scroll: Smooth Animated Scroll (Top to Bottom and Bottom to Top)

<html xmlns=”http://www.w3.org/1999/xhtml”> <head> <title></title> <style type=”text/css”> body { font-family: Arial; font-size: 10pt; } #scrollToTop, #scrollToBottom { cursor:pointer; background-color:#5824F2; display:inline-block; height:40px; width:40px; color:#fff; font-size:16pt; text-align:center; text-decoration:none; line-height:40px; } </style> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script> <script type = “text/javascript”> $(function () { $(‘#scrollToBottom’).bind(“click”, function () { $(‘html, body’).animate({ scrollTop: $(document).height() }, 1200); return false; }); $(‘#scrollToTop’).bind(“click”, function () { $(‘html, body’).animate({ scrollTop: 0 }, 1200); return false; }); }); </script> </head> <body> <div align = “right”> <a href=”javascript:;” id=”scrollToBottom”>▼</a> </div> The history of computer science began long before the modern discipline of computer science that emerged in the 20th century, and hinted at in the centuries prior.[dubious – discuss][citation needed] The progression, from mechanical inventions and mathematical theories towards the modern computer concepts and machines, formed a major academic field and the basis of a massive worldwide industry.[1] The earliest known tool for use in computation was the abacus, developed in period 2700–2300 BCE in Sumer.[citation needed] The Sumerians’ abacus consisted of a table of successive columns which delimited the successive orders of magnitude of their sexagesimal number system.[2]:11 Its original style of usage… Read More

Read More