Posts

Showing posts from October, 2013

Redirect SharePoint NewForm.aspx to "Thank you" page once user saved record.

Requirement : Redirect NewForm.aspx to "Thank you" page once user saved record. Add ThankYou.aspx at same location where NewForm.aspx is exist (I used SP2010 designer) Add below JavaScript in content editor web-part function PreSaveAction() { var URL = location.pathname.replace('NewForm.aspx','ThankYou.aspx'); if(GetUrlKeyValue('IsDlg')==='1'){ URL+="?IsDlg=1"; } $("#aspnetForm").attr('action',location.pathname+"?Source="+URL); return true; }

Divide share point newform.aspx in sections.

Requirement : Divide SharePoint newform.aspx in sections. Solutions : Added heading for each sections. Function AddTrWithTd(ColumnNameWhereYouWantToAddHeading, FirstColumnText, SecondColumnText) If you want SecondColumn then pass "&nbsp;" Call this function in document.ready. Change TD style and color as per requirement. function AddTrWithTd(title,cell1Html,cell2Html) {         var header_h3 = document.getElementsByTagName("h3");         for (var i = 0; i < header_h3.length; i++) {             var el = header_h3[i];             var foundField;             if (el.className == "ms-standardheader")             {                 for (var j = 0; j < el.childNodes.length; j++)                 {         ...

Hide row on SharePoint newform.aspx.

Requirement : Hide row on SharePoint newform.aspx Solution : Add content editor web-part on page and call below JavaScript functions. (You can call function in document.ready) function HideField(title, hide) {         var header_h3 = document.getElementsByTagName("h3");         for (var i = 0; i < header_h3.length; i++) {             var el = header_h3[i];             var foundField;             if (el.className == "ms-standardheader") {                 for (var j = 0; j < el.childNodes.length; j++) {                     if (el.childNodes[j] && el.childNodes[j].innerHTML) {                         if (el.childNodes[j].innerHTML == title || el.childNodes[j].innerHTML.startsWith(title)...

Validate SharePoint people picker before Save.

Scenario: When user enters firstName LastName in people picker and click SharePoint save, without validating user. Site shows error message Reason : We have 30,000+ user and 5+ domains so request time-outs. Fix : Ask user to validate people picker before save. JavaScript : function getPickerInputElement(identifier) {     var tags = document.getElementsByTagName('DIV');     for (var i=0; i < tags.length; i++)     {             var tempString = tags[i].id;                 if ((tempString.indexOf('UserField_upLevelDiv') > 0))         {             if(identifier == tempString)             {                 var innerSpans = tags[i].getElementsByTagName("SPAN");                   for(var j=0; j < inner...