Skip to main content

Posts

Showing posts with the label jQuery

Populate people picker field with logged in user in SharePoint using JS

Please use below code to populate people picker in SharePoint online, <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(function () { setTimeout(function () { SetUserFieldValue('AuthorName'); }, 1000); }, 'clientpeoplepicker.js'); //Set PeoplePicker Value function SetUserFieldValue(fieldName) { try{ var userAccountName = _spPageContextInfo.userLoginName; //PeoplePicker Object var peoplePicker = $("div[title='" + fieldName + "']"); //PeoplePicker ID var peoplePickerTopId = peoplePicker.attr('id'); //People PickerEditor var peoplePickerEditor = $("input[title='" + fieldName + "']"); //Set Value to Editor peoplePickerEditor.val(userAccountName); //Get Client PeoplePicker Dict var peoplePickerObject = SPClientPeoplePicke...

How to delete duplicates from SharePoint list using JSOM

How to delete duplicates from SharePoint list using JSOM, Credit: Thulasi Pasam Reference:  https://community.nintex.com/thread/8516 Note: Make sure the reference file paths Make sure the column to test duplicate on CAML query Update your SharePoint list name <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=5, IE=8, IE=9, IE=10" > </head> <body> <div Id="myDiv" style= "width: 75%;"> <table id="tblHeading"  width = "100%" align = "left"> <tr style ="width:100%;"> <td><input type= "button" onclick="Delete()" align = "Center" alt="Delete Duplicates" value="Delete...

Show confirmation message on click of save in OOB list forms in SharePoint

Show confirmation message on click of save in OOB list forms in SharePoint, add the below script in each OOB list form page. <script type="text/javascript" language="javascript" src="/sites/dev/Style%20Library/Scripts/jquery-3.1.0.min.js"></script> <script type="text/javascript"> function PreSaveAction() {   if($('[id*="Update"]').is(':checked')){ return (confirm("This item has value of Update as “Yes”. Are you sure you want to save this item?")); } else{ return true; } } </script>

GetListItem and UpdateListItem using SPServices in MOSS 2007

GetListItem and UpdateListItem using SPServices in MOSS 2007 $(document).ready(function() { var itemToUpdate = GetListItem(); UpdateListItem(itemToUpdate); }); function GetListItem(){ var today = new Date(); var dayOfWeek = today.getDay(); var itemID = 0; var out = ""; var titleField = "<FieldRef Name='Title' />"; var descriptionField = "<FieldRef Name='Description' />"; var viewFields = "<ViewFields>" + titleField + descriptionField + "</ViewFields>"; var myQuery = "<Query>" + "<OrderBy>" + "<FieldRef Name='ItemOrder' Ascending='True'/>" + "</OrderBy>" + "</Query>"; $().SPServices({ operation: "GetListItems", async: false, listName: "MyList", CAMLQuery: myQuery,   CAMLViewFields: viewFields, completefunc: fun...

Resources for jQuery with SharePoint

Here are some nice resources for jQuery with SharePoint, http://msdn.microsoft.com/en-us/library/gg701783%28v=office.14%29.aspx http://blogs.msdn.com/b/yojoshi/archive/2010/06/17/using-jquery-with-sharepoint-2010.aspx http://www.codeproject.com/Articles/544538/JQuery-with-SharePoint-2010 http://www.threewill.com/2012/01/adding-jquery-to-sharepoint/