Posts

How to get SharePoint list last updated details using REST

Image
SharePoint list last updated details using REST You can use the below code to get last updated date of a SharePoint list which may be used in your any BAU requirement. Code -  function lastItemModified(){    $.ajax({     url: url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Dummy')/Items?$select=Modified&$orderby= Modified desc",,     method: "GET",     headers: {       "Accept": "application/json; odata=verbose"     },     async: false,     success: function success(data) {               var d = data.d.results[0].Modified.substring(0, data.d.results[0].Modified.lastIndexOf("T"));           var year = d.split("-")[0];           var month = d.split("-")[1];               var day = d.split("-")[2];         ...

How to customize Data Tables

Image
Customizing Data Tables -  In the below scenario i have changed data table button names, customize paginate, customize search, customize infoFiltered etc. You just need to get your data from a data source and apply the below code. Code -  $("#tbl").DataTable({         dom: 'Bfrtip',         buttons: [{           extend: 'pdf',           text: 'Pdf'         }, {           extend: 'excel',           text: 'Excel'         }],         language: {           paginate: {             next: '→', // or '→'             previous: '←' // or '←'            },           search: '🔎',           info...

How to get the values of selected check boxes in a collection using jQuery

Image
Get the values of selected check boxes using jQuery In the below scenario we have used jQuery each loop and join function, with the help of these we can get selected values of check boxes. HTML -          <h3>Select your favorite sports:</h3>         <label><input type="checkbox" value="football" name="sport"> Football</label>         <label><input type="checkbox" value="baseball" name="sport"> Baseball</label>         <label><input type="checkbox" value="cricket" name="sport"> Cricket</label>         <label><input type="checkbox" value="boxing" name="sport"> Boxing</label>         <label><input type="checkbox" value="racing" name="sport"> Racing</label>         <label><input type="checkbox" value="swimming" n...

How to Change Formatting of SharePoint List's Date Type Column using javascript

Image
Change Formatting of SharePoint List's Date Type Column using javascript SharePoint list's date type column gives us date in the below format :- 2020-04-02T20:17:46.384Z You can modify this format according to your need, below is an explanation of this -  $.each(data.d.results, function(key, value) {                    var d = value.Created.substring(0, value.Created.lastIndexOf("T"));           var year = d.split("-")[0];           var month = d.split("-")[1];               var day = d.split("-")[2];             alert(day +"-"+ month +"-"+ year);                                   }         });  Output Date format would be :-  02-04-2020

How to send Email using REST Api

Image
Send Email using REST Api Sometimes we need to use Rest api for sending emails as we have its utility - " /_api/SP.Utilities.Utility.SendEmail" which is responsible for this feature. You can pass parameters in the below functions such as Subject, To, CC and body. For sending multiple users we need to defined  to,cc as array collection. Code -  function SendEMail(subject,to,cc,body){         $.ajax({             contentType: 'application/json',             url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.Utilities.Utility.SendEmail",             type: "POST",             data: JSON.stringify({                 'properties': {                     '__metadata': {                         't...

Set SharePoint List forms fields enable or disable using jQuery

Image
How to set SharePoint List forms fields enable or disable using jQuery Go to a SharePoint List Form. Edit the form and add script editor web part to it. Insert the below code in the script editor web part. Code- <script src="../../SiteAssets/JS/jquery-3.1.1.min.js" type="text/javascript"></script> <script src="../../SiteAssets/JS/HideFields.js" type="text/javascript"></script> HideFields.js Code- $(document).ready(function(){ $("input[title='Title Required Field']").attr("disabled", "disabled");  $("select[title='request type Required Field']").attr("disabled", "disabled"); $("textarea[title='description']").attr("disabled", "disabled"); $("input[title='requested Go-Live Date Required Field']").attr("disabled", "disabled"); $("textarea[title...

Limiting SharePoint People Picker field to an specific group of people

Image
How to Limit SharePoint People Picker field to an specific group of people In many cases we need to choose people within a specific SharePoint group, in that scenario we go to the column settings as shown below and under choose from section we select a specific SharePoint group. The above screen shot is for a people picker type field and we can change its settings as shown above.