Skip to main content

Posts

Showing posts with the label SharePoint

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...

Show modified by author and date in all pages in O365 SharePoint site

Show modified by author and date in all pages in O365 SharePoint site using below script, $(document).ready(function() { GetEditorAndDate(); });  // end document-ready function GetEditorAndDate() { var relativePageURL = _spPageContextInfo.serverRequestPath; var siteURL = _spPageContextInfo.webAbsoluteUrl; var profileUrl = "https://myorg.sharepoint.com/sites/devsite/"; var query = siteURL + "/_api/web/getfilebyserverrelativeurl('/"+ relativePageURL +"')?$select=TimeLastModified,ModifiedBy/Title,ModifiedBy/LoginName&$expand=ModifiedBy"; var call = $.ajax({ url: query, type: "GET", dataType: "json", headers: { Accept: "application/json;odata=verbose" }     }); call.done( (function (data, textStatus, err){  rawModifedBy = data.d.ModifiedBy.Title  prettiedModifiedBy = rawModifedBy.split(', ')[1]+' '+ rawModifedBy.split(', ')[0]  rawModi...

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...

Color coding the list status column in SharePoint 2013

Below formula can be used to color code the list status column in SharePoint 2013, ="<DIV style='font-weight:bold; font-size:42px; color:"&CHOOSE(RIGHT(LEFT(Priority,2),1),"red","orange","green")&";'>•</DIV>" Credit goes to Junaid Khan here:  https://junaidsk.wordpress.com/2014/02/25/color-coding-in-sharepoint-lists-using-calculated-columns/

People Picker dialogue is blank / Choose folder dialogue under upload documents is blank

People Picker dialogue is blank / Choose folder dialogue under upload documents is blank Resolution : This is because of the SQL Injection rules in the IIS site. Follow the below steps to fix the issue: Go to IIS Manager (inetmgr) Expand the Sites-> Select the Migration farm URL In the right side pane-> double click on "Request Filtering" Under the rules tab -> Remove the  rule for SQL injection Do the same on the extended site and as well on all the WFE servers in the farm Hope this helps someone.

Nice Articles for REST in SharePoint using Open Data(OData)

Following are the great resources I found useful for REST in SharePoint, Excerpts are, In practice, many firewalls and other network intermediaries block HTTP verbs other than GET and POST. To work around this issue, WCF Data Services (and the OData standard) support a technique known as "verb tunneling." In this technique, PUT, DELETE, and MERGE requests are submitted as a POST request, and an X-HTTP-Method header specifies the actual verb that the recipient should apply to the request. The SharePoint REST interface is based on the REST-based Open Data protocol (OData) for Web-based data services, which extends the Atom and AtomPub syndication formats to exchange XML data over HTTP. Because OData is a platform-independent open standard, the SharePoint REST interface is a great way to access SharePoint list data from platforms on which the CSOM may be unavailable to you, such as from non-Windows–based operating systems. However, the REST interface only provi...

"cannot update library or list" while publishing InfoPath form

This error comes when the column limit is exceeded in InfoPath form library because of the setting change happens when we take template from QA to PROD environments. Anyone should never use "Quick Publish" button on the ribbon of InfoPath in high risk environments and check every column mapped in Property Promotion window of publish wizard. The following CSOM code can be used to delete the duplicate columns(which are read-only) created because of the above error, ClientContext context = new ClientContext(sharePointSiteURL); Site oSite = context.Site; context.Load(oSite); Web web = context.Web; List doclist = web.Lists.GetByTitle("LibraryName"); context.Load(doclist); context.ExecuteQuery(); FieldCollection fieldCollection = web.Lists.GetByTitle("LibraryName").Fields; foreach (Field column in fieldCollection) {     if (column.InternalName.Equals("ColumnName"))     {         column.ReadOnlyField = false; ...