Friday, 21 June 2013

Create and Read cookie in SharePoint 2010.

Problem Description:

Create and Read cookie in SharePoint 2010.
Resolution:

<script type="text/javascript">

/* Create Cookie Function*/
    createCookie("CookieVarLocation",VarLocation);
/* Read Cookie Function*/
    var x =readCookie("CookieVarLocation");
   function createCookie(name,value)
   {
     var expires = "";
     document.cookie = name+"="+value+expires+"; path=/";
   }
   function readCookie(name)
  {      
    var nameEQ = name + "=";
     var ca = document.cookie.split(';');
     for(var i=0;i < ca.length;i++)
     {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
       return null;
    }
</script>
Feel free to revert in-case of any query...
Product Applies To:
·         SharePoint Server 2010
·         SharePoint Foundation 2010
·         SharePoint Server 2013

Fetch current login user data from active directory using JavaScript in SharePoint

Problem Description:

Fetch current login user data from active directory using JavaScript in SharePoint.

Resolution:

<script type="text/javascript">
/* getUserName function is use to find Current System User */
function getUserName()
{
 var wshNetwork = new ActiveXObject("WScript.Network");
 var userName = wshNetwork.UserName;
 return userName;
}

function getAD(userName)
{
 //var name = userName.split(".");
 objConnection = new ActiveXObject("ADODB.Connection");
 objConnection.Provider="ADsDSOObject";

 objConnection.Open("ADs Provider");

 objCommand = new ActiveXObject("ADODB.Command");
 objCommand.ActiveConnection = objConnection;

 objCommand.CommandText = "SELECT sAMAccountName, givenName, SN, mail,physicalDeliveryOfficeName FROM 'LDAP://DomainName.com/DC=Domain,DC=com' WHERE objectCategory='user' and sAMAccountName = '"+userName+"'";

 /* Next up is the command itself.*/
 objRecordSet = objCommand.Execute();

 /* Then we execute the command */
 /* Once executed, the command will return an enumeration of the results.*/

 var userMail,lastName,firstName;
 if (objRecordSet.RecordCount == 1) {
  objRecordSet.Movefirst;
  userMail = objRecordSet.Fields("mail").value;
  firstName = objRecordSet.Fields("givenName").value;
  lastName = objRecordSet.Fields("sn").value;
  samaccountname= objRecordSet.Fields("samaccountname").value;
  physicalDeliveryOfficeName= objRecordSet.Fields("physicalDeliveryOfficeName").value;
 }
 else
 {
  userMail = "";
  firstName = "";
  lastName = "";
  physicalDeliveryOfficeName = "";
 }
 objConnection.Close;
 return userMail+";"+firstName+";"+lastName+";"+physicalDeliveryOfficeName;
}

var AD = getAD(getUserName()).split(";");

var mail = AD[0];
var firstName = AD[1];
var lastName = AD[2];
var Office = AD[3];
</script>


References:

1) In objCommand.CommandText make connection string properly.
2) In Select query use column name of active directory from which you want data.
Refer this link for column name: http://ebookbrowse.com/aducproperties-xls-d22488526



Product Applies To:
·         SharePoint Server 2010
·         SharePoint Foundation 2010
·         SharePoint Server 2013

Feel free to revert in-case of any query...

Saturday, 15 June 2013

Anchor tag in calculated column of SharePoint 2010

Problem Description:

Anchor tag in calculated column of SharePoint 2010.


Resolution:

Syntax:

  • In formula section add Anchor tag in double quotes as shown below.
  • Write your redirection page path in "href" attribute.
  • Keep column type as Number.


Example:
="<a href=/Lists/RequestList/CustomerCancelForm.aspx?ID="&ID&">Cancel</a>"




Product Applies To:
·         SharePoint Server 2010
·         SharePoint Foundation 2010
·         SharePoint Server 2013

Tuesday, 28 May 2013

Add JavaScript file in SharePoint master page

Problem Description:

How to add JavaScript file in SharePoint master page.

Resolution:


Follow below steps:
  • Open your site in designer.
  • Select Master pages option.



  • Select V4.master, right click on it and select "Edit File in Advance Mode" option.



  • In V4.master file search "<ShararePoint:Scriptlink" tag.
  • As shown in below figure add your JavaScript file.



Product applies to:

  • SharePoint Server 2010
  • SharePoint Foundation 2010
  • SharePoint Server 2013

Feel free to revert in-case of any query...

Friday, 24 May 2013

Error Message:
SharePoint list error: lookup and workflow status columns exceed the threshold.

Problem Description:

Users get this error when accessing a SharePoint list:

This view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold (8) enforced by the administrator.

Resolution:

Follow below steps:
1.    Open the SharePoint Central Administration
2.    Application Management
3.    Manage Web Application
4.    Select Your Web Application
5.    General Settings
6.    Resource Throttling
7.    By default List View Lookup Threshold is 8 change it as per your requirement and
8.    Finally click OK to save it.

Feel free to revert in-case of any query...

Product Applies To:
·         SharePoint Server 2010
·         SharePoint Foundation 2010
·         SharePoint Server 2013