SharePoint (2003 thru Online): February 2015

Tuesday, February 17, 2015

Set SharePoint 2007 Web application/Site Colelction into Read Only.




Use the SharePoint interface to set a Web application/Site Collection to read only. This is normally done as a precursor to an upgrade or migration.

Steps
  • Go to “Application Management > Site Collection quotas and locks”
  • Choose the Site Collection to see what the status is
  • Set to read only and set the message the user sees

Thursday, February 5, 2015

Default User login on Domain (Windows 7)

To do it on the PC, run gpedit.msc, browse to 

Computer Configuration >>
     Windows Settings >>
         Security Settings >>
             Local Policies >>
                Security Options
and look for 

'Interactive login: Do not display last user name' and set it to 'disabled'.
'Interactive login: Display user information when the session is locked' and set it to 'User display name only'.




Wednesday, February 4, 2015

Trick to Edit Web Part pages ( NewForm, DispForm & EditForm )


Sometimes we need to edit and add scripts to the NewForm.aspx, DispForm.aspx & EditForm.aspx based on user requirements.


Here we are trying to add the ID field in the NewForm.aspx.

First, append ?ToolPaneView=2 to the URL to switch to edit mode as shown below.

http://spdev.dev.com/Lists/Announcements/NewForm.aspx?ToolPaneView=2


Next, add a hidden Content Editor Web Part (CEWP) to the page

Then add the below script in the source editor of the CEWP, To Hide the fields.

<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideFields");


function findacontrol(FieldName) {


   var arr = document.getElementsByTagName("!");    

// get all comments
   for (var i=0;i < arr.length; i++ )
   {
      // now match the field name
      if (arr[i].innerHTML.indexOf(FieldName) > 0)
      {         return arr[i];      }
   }
}

function hideFields() {


   var control = findacontrol("Title");

   control.parentNode.parentNode.style.display="none";
   control = findacontrol("Link");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("Expiry Date");
   control.parentNode.parentNode.style.display="none";
}
</script>

________________________________________________________

Next, add a hidden Content Editor Web Part (CEWP) to the page

Then add the below script in the source editor of the CEWP, To Display the ID in the first row.

<script type="text/javascript">

// Item ID in DispForm.aspx and EditForm.aspx


function DisplayItemID()

{
var regex = new RegExp("[\\?&]"+"ID"+"=([^&#]*)");
var qs = regex.exec(window.location.href);
var TD1 = document.createElement("TD");
TD1.className = "ms-formlabel";
TD1.innerHTML = "<h3 class='ms-standardheader'>Issue ID</h3>";
var TD2 = document.createElement("TD");
TD2.className = "ms-formbody";
TD2.innerHTML = qs[1];
var IdRow = document.createElement("TR");
IdRow.appendChild(TD1);
IdRow.appendChild(TD2);
var ItemBody = GetSelectedElement(document.getElementById("idAttachmentsRow"),"TABLE").getElementsByTagName("TBODY")[0];

// To display the ID in the first row
ItemBody.insertBefore(IdRow,ItemBody.firstChild);

// To display the ID in the last row (enable the below line)
//ItemBody.appendChild(IdRow);

}
_spBodyOnLoadFunctionNames.push("DisplayItemID");
</script>

In the above script, you can change the "Issue ID" to any other text as you need.
You need to repeat the above steps to get it on to the EditForm.aspx.