Wednesday, December 24, 2014


SharePoint 2013/2010 -Go Up folder in Document Library

Issue:
Some time when we customize the tile/navigation/breadcrumb, the link to document folder go up folder by will go missing. Here is a simple hack for it.

Resolution:
Just paste this code in content editor or script editor, and add an image suitable with updating the link.
PS: correct the links of folder to you library and site location. (highlighted part)

<script type="text/javascript">
function getParameterByName(name) {    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),        results = regex.exec(location.search);           return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));}

function GoUPFolder(){
if(getParameterByName('RootFolder')!="" && getParameterByName('RootFolder')!= "/teams/site/doclib"){
var url = getParameterByName('RootFolder').split("/");
var upfolder="";
for( var i=1; i< url.length-1; i++)
{upfolder=upfolder+"/" + url[i];}
window.location.href = "/teams/site/doclib/?RootFolder=" + upfolder;}
else{window.location.href = "/teams/site/doclib";}
}
</script>

<div id="divUpLink">
<img onclick="GoUPFolder();" style="cursor: pointer;" src='/teams/site/images/UpButton.gif'/>
</div>



Happy Browsing!
Relax..

Friday, October 10, 2014

SharePoint 2013/2010 - Model Dialog errors out when you use Site Pages


Issue
When you try to include a page from Site Page library in a Model Dialog box, SharePoint gives error with query parameter &IsDlg=1 and if you open the same page in normal browser without &IsDlg=1 , then it works fine.

Resolution
SharePoint  model pop will look for the webpart layout in the model pop page and the Site Pages are made of wiki layout, it fails. Try creating the page in the Pages Library with webpart layout and use in the model dialog, then it will work fine.



Happy Browsing!
Relax..

Friday, September 19, 2014

SharePoint 2013 - Setting up folder level Alert


If you are looking to set alerts for a specific folder and its contents, then please follow the steps


1. Look at the folder you want alerts on, from within the library, don't go into the folder.
2. Click on the '...' setting button for the folder you want an alert on
3. Click on the next '...' button and choose 'View Properties'
4. You should now be looking at the properties of the folder you want an alert on
5. Press the 'Alert Me' button from the ribbon.
6. Please Ensure the Alert Name includes the Document Library and its folder name . ex: Documents:Images
6.  Click on OK.

This should set the alert on the folder only, not the parent library.


Happy Browsing!
Relax..

Thursday, September 18, 2014

SharePoint 2010/2013 - To hide header ribbon row on the custom model dialog .

In many times, we want to hide the ribbon (with edit or other options) from the popup or some pages of SharePoint pages. In order to hide such cases, here is the quick fix.

Add the below code in the script editor . In order to apply this in generic, try a common JS file or may be a text file and then load in the pages using CEWP or script editor webpart

<style>
#RibbonContainer{
display:none;
}
#globalNavBox{
display:none;
}
#s4-ribbonrow{
height:0px !important;
}
</style>



Happy Browsing!
Relax..

Wednesday, September 10, 2014


Simple marquee to slide text on mouse hover to start/stop text with anchor tag.


Add the below code in HTML/ CEWP to slide the text left to right. you can also include teh text from Object Model to display dynamically from List.


<div align="center" >
                        <marquee scrollamount="3" style="color: #900000; font-weight: bold; font-size: 20px;    width: 600px;">
<a href="#" onmouseover="this.parentNode.stop();" style="font-size:18px; color:#900000; font-weight:bold;" onmouseout="this.parentNode.start();">Simple marquee. On mouse hover to stop.</a>
</marquee>
  </div>



Happy Browsing!
Relax..

Friday, September 5, 2014

SharePoint 2010/2013 - To hide the List from view lists page.

Many times we create so many list and if we want to hide the list being appear in the setting.aspx page then below steps can be performed.

To Hide List From viewlsts.aspx
  • Open the Site in the SharePoint Designer
  • Select the list which you want to hide and open its setting page section
  • In the settings section >> General Section  - Check the "hide from browser" option
  • Click on Save.
To UnHide List From viewlsts.aspx
  • Open the Site in the SharePoint Designer
  • Select the list which you want to hide and open its setting page section
  • In the settings section >> General Section  - UnCheck the "hide from browser" option
  • Click on Save.


Happy Browsing!
Relax..

Friday, August 15, 2014

SharePoint 2013 - Activate Feature using Client Object Model

You can activate the Site Collection Features / Site Feature using Client Object Model (CSOM) . All you need to do is to put the below code in the script editor or Content Editor Webpart in you page.

 <script src="https://Servername/Shared%20Documents/jquery-1.8.3.min.js" type="text/javascript"></script>

<script type="text/javascript">
var context = SP.ClientContext.get_current();
$(document).ready(function () {
var site = context.get_site();
context.load(site);
context.executeQueryAsync(function () {
site.get_features().add("Enter Feature ID Here", true, 0);
context.executeQueryAsync(Sucess() {
function("Sucess!");
},
function(sender, args){
alert("Error : " + args );
});
},
function (sender, args) {
alert("Oops. Sorry! " + args);
});
});
</script>

 

Happy Browsing!
Relax..

 

Wednesday, July 2, 2014

SharePoint - Troubleshoot / Help 404 error in SharePoint

Troubleshoot steps if you are getting 404 error for the site collection and central admin is loading properly. 404 generally occurs when your request is hitting the server and server is unable to find/servers your requested page.
  1.  Make sure SharePoint services are running, restart IIS web sites have started,     IIS application pools have started and Database are up
  2. Check ping is receiving reply from network.
  3. Try accessing the site by server name with full domain and port number.
  4. Check the Alternate Access Mapping is correctly configured.  IIS can handle the connection to the root site, but without this information added, SharePoint cannot properly handle the requests to your other site collections.
  5. Check your permission level in the site collection or farm and Database.
  6. Check the http://ServerURL/_layouts/settings.aspx is loading properly. Come times landing page may have error.
  7. Check the authentication is enabled in the IIS for windows and default logins.
  8. Check the Firewall port is open to accept request at 80 port. Open firewall settings. Then search for something like - Allow program or feature to allow through firewall. If in the list World Wide Web services (HTTP) is unchecked, check it and restart the system
  9. Check the HOST file entry for the name/ URL / typos
  10. Check the bindings in the IIS for the port listener.Make sure the default site is stopped. If you see bindings that look like the following:
    ID 1: Bindings: *:80
    ID 2: Bindings: www.yoursite.com:80
  11. Check the Event Viewer log - this will help for most of the issues debugging. 
  12. Check the ULS log is any authentication is failing inside. Some times bin folder or app folder may be locked down.


    If this issues occurs intermittently then probably you need to check this article for remounting DB.
Happy Browsing!
Relax..

Wednesday, June 25, 2014

JavaScript: Easy way to Cache objects in Local Storage/ Client Browser in JavaScript

Here is a easy way to store and retrieve  your java script objects ( even more than 4KB) in the local /Client browser . I'm using jStorage for this method and jStorage supports storing Strings, Numbers, JavaScript objects, Arrays and even native XML nodes. jStorage also supports setting TTL values for auto expiring stored keys and - best of all - notifying other tabs/windows when a key has been changed or publishing/subscribing to events from the same or another tab/window, which makes jStorage also a local PubSub platform for web applications.


 < script src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js">
< script src="http//code.jquery.com/jquery-1.9.1.min.js">
< script src="jstorage.js">


< script type="text/javascript">
var testObject = "test123"; /* Sample Data. You can fetch the objects from Server and store it*/

// Check if "key" exists in the storage
var value = $.jStorage.get("key");
if(!value){
    $.jStorage.set("key",testObject);
}
< /script >


Here you go, Now its easy to store to the cache with bigger data. hope this helps.
Article Source and .js file available at : www.jstorage.info

Happy Browsing!
Relax..

Thursday, June 19, 2014

SharePoint 2013 - Client Object Model - Document Library Author error and SP.UserProfiles.PeopleManager Error Handling


If you are getting the PeopleManager as object referance error, then try this method.

Try to load the script file above the calling function.
< script src="/_layouts/15/sp.userprofiles.js" type="text/javascript" >

Try to wrap the function inside the SP.SOD.executeFunc. This will make sure to load the profile manager.

   SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {
   SP.SOD.executeFunc('userprofile', 'SP.UserProfiles.PeopleManager', function() {
    var targetUser = "Domain\\" + createdBy.split('\\')[1]; //Splitting to get the userID
    var clientCtx = new SP.ClientContext.get_current();
    var peopleManager= new SP.UserProfiles.PeopleManager(clientCtx );
    var i = peopleManager.getPropertiesFor(targetUser)
    //This is not yet finished till you execute the query.
   ctx.load(i);
    ctx.executeQuery(
    function () {
        alert("Display Name:" + i.get_displayName());
    } , function (sender, args) {
        alert(JSON.stringify(args));
    });

   });

});




If you are not able to get Author field in Document Library , try this field Created_x0020_By. This will give you the value as domain\\userid. I have splited here to get the exact user ID. (I'm not sure to get the display name from this. tried to fetch from user profile. bu the function was loading post as async. So opted for 2nd option using WF)

Happy Browsing!
Relax..

Tuesday, June 17, 2014


SharePoint 2013- Get/Fetch SharePoint User Details using JavaScript/Client Object Model

To fetch the current user details in the SharePoint using client object model, Add a new Content Editor on your page and insert the below code. This will display the user id, name and email of the current logged in user.

< script type="text/javascript" >
//Delay until the page loads
ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
var currentUser;
function init(){
    this.clientContext = new SP.ClientContext.get_current();
    this.oWeb = clientContext.get_web();
    currentUser = this.oWeb.get_currentUser();
    this.clientContext.load(currentUser);
    this.clientContext.executeQueryAsync(Function.createDelegate(this,this.QuerySucceeded), Function.createDelegate(this,this.QueryFailed));
}

function QuerySucceeded() {
    document.getElementById('userLogin').innerHTML = currentUser.get_loginName();
    document.getElementById('userName').innerHTML = currentUser.get_title();
    document.getElementById('userEmail').innerHTML = currentUser.get_email();
}

function QueryFailed(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}

< / script >
<!-- Display on the screen.-->
< div  >Current User Details:
    < span id="userLogin"></ span >
    < span id="userName"></ span >
    < span id="userEmail"></ span >
< /div  >


PS: White Space are added in the HTML tag to avoid the blog to hide the controls. Please clear the white space on the tags to use at your end.


Article Source
Happy Browsing!
Relax..
 

Monday, June 2, 2014

SharePoint 2010/2013 - Today as Calculated Column - Used for date age calculation

 

SharePoint does not allow the Calculated field with function like [Today] or [Me] , And when we required to calculate a age of an issue created from today's date, this will be an issue.  Here is  a simple way to fix this issue

  1. Add a new column to list with Today as Column name and select Date Time as Type.
  2. Select the default value as Today's date and save it 
  3. Create  a new column as Age and select type as calculated field. Use the below formulate to get the date difference. 
  4.         =IF([Created]="","NA",Today-[Created]) 
  5. Select the data type returned from this formula as Number and set number of decimals to 0 and save it.
  6. Now delete the Today columns that is created from step 1. ( if you don't delete this , answer will be based on this column which will be empty and you'll get a -ve value).
  7. Now your list display difference as the age in days.
Here , you can use any other date column that you have created. This formula will give you the result as difference between today and created date. EX: Created Date = 5/1 and Today is 6/2, then Age = 32.  And for custom columns if no date is present, this will display NA.


PS: The calculated fields will not auto refresh every day. For auto refresh, it has to go through custom code or timer job.

Happy Browsing!
Relax..

 

Thursday, May 29, 2014

SharePoint 2010/2013 - Notifications options



SharePoint provide OTB model dialog which can be used from client side to show a message or loading splash which you load a application page on your model dialog. Below are the options that can be used in a content editor or JavaScript file on your SharePoint page.
Add this tag to avoid null ref error ( like 'SP.UI.Notify' is null or not an object or 
Message: 'SP.UI.ModalDialog' is null or not an object).
 < script src="/_layouts/SP.UI.Dialog.js" type="text/javascript" >
or
Try adding this in code after option declaration while calling popup.
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

To give a Loading Notification for a model dialog. 
Start of displaying the notification
var waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Working on it', 'Please wait while we load your screen...', 70, 340);
To Stop the loading Screen
waitDialog.close();
If you want to display notification in the top right corner then use this.
To Start notification
var notification;
ExecuteOrDelayUntilScriptLoaded(function () 
notification = SP.UI.Notify.addNotification("BI Charts are getting loaded!", true);
});
 // ExecuteOrDelayUntilScriptLoaded this function prevent the null ref error and it wait till the SP.UI.Dialog.js loads.
To Stop notification
SP.UI.Notify.removeNotification(notification);
---------Example-----------------------

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

var statusId = '';
var notifyId = '';

function AddNotification() {
    notifyId = SP.UI.Notify.addNotification("Hello World!", true);
}

function RemoveNotification() {
    SP.UI.Notify.removeNotification(notifyId);
    notifyId  = '';
}

function AddStatus() {
    statusId = SP.UI.Status.addStatus("Status good!");
    SP.UI.Status.setStatusPriColor(statusId, 'red');
}

function RemoveLastStatus() {
    SP.UI.Status.removeStatus(statusId);
    statusId = '';
}

function RemoveAllStatus() {
    SP.UI.Status.removeAllStatus(true);
}

< /script >
 
PS: Please correct the tags spacing and add js file ref.

Source: https://msdn.microsoft.com/en-us/library/office/ee658473%28v=office.14%29.aspx

Happy Browsing!
Relax..

Saturday, May 10, 2014

SharePoint 2010 - Remove Chart Webpart  Default Options Display



To hide the legends and Other information ( Data options) from the Chart Webpart, Set ShowToolbar="False" from the SharePoint Designer in XSLT mode.



Happy Browsing!
Relax..

Friday, April 18, 2014

SharePoint 2013/2010 - Remove Columns Name from Group View

 To remove the column name from group view and retaining the collapse and expand option,copy and paste the below javascript in the page using content editor or script editor.

JavaScript (SharePoint 2013/SharePoint 2010):
<script type="text/javascript" language="javascript">
        _spBodyOnLoadFunctionNames.push("HideHeaders");
        function HideHeaders() {
            var elements = getElementsByClassName(document, "td", "ms-gb");
            var elem;
            for (var i = 0; i < elements.length; i++) {
                elem = elements[i];
                elem.childNodes[0].childNodes[1].nodeValue = "";
                elem.childNodes[1].nodeValue = elem.childNodes[1].nodeValue.replace(':', '');
            }
            elements = getElementsByClassName(document, "td", "ms-gb2");
            for (var i = 0; i < elements.length; i++) {
                elem = elements[i];
                elem.childNodes[1].childNodes[1].nodeValue = "";                elem.childNodes[2].nodeValue = elem.childNodes[2].nodeValue.replace(':', '');
            }
        }
        function getElementsByClassName(oElm, strTagName, strClassName) {
            var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
            var arrReturnElements = new Array();
            strClassName = strClassName.replace(/\-/g, "\\-");
            var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
            var oElement;
            for (var i = 0; i < arrElements.length; i++) {
                oElement = arrElements[i];
                if (oRegExp.test(oElement.className)) {
                    arrReturnElements.push(oElement);
                }
            }
            return (arrReturnElements)
        }
    </script>

Thanks to Source Article: http://amitphule.blogspot.com/2011/10/hiding-group-headers-from-sharepoint.html  

Happy Browsing!
Relax..

Wednesday, April 16, 2014

SharePoint  - Remove Columns Filter from List view

In order to remove the filter option from the list view and retain he sort, 
  1. Open the list view in the SharePoint Designer.
  2. Search for the inside   or column name that you want to hide filter option. The columns can be initially seen like this -
  3. Add the tags LinkToItem="TRUE" Filterable="FALSE" FilterDisableMessage="No filter available " tot the field names to hide the filter. After adding the tag looks like this -  
This will hide the column filter  and retains the sorting option in the list View. To take off the sorting , add Sortable="FALSE". 



Happy Browsing!
Relax..

Saturday, April 5, 2014

SharePoint 2013 - Image Slider from Content Query webpart with no coding

5 easy steps to create image slider from content query webpart with no coding!

I was looking for the image slider that can configured easily and effective with using OTB feature and I got different methods but some where I felt this can be made independent. Hence I used the blog from this article and image slider from basic Slider site and I merged with Content query webpart to get easy to use image slider.

Now to start in details

  1. Configure the content type as shown in this article.  ( this is used to order images and filter images) 
  2.  Create a picture library in your site and upload your images of same size. Now edit properties of the images, select the Slider Content Type (if you configure from step 1) then enter title, comments, url, sort order, start and end dates  etc for the images. This will be used to determine which image to be shown in the slider and in which order. 
  3.  Upload these files to any document library or style library or with your custom master page. 
  4.  Now, on the page where the image slider to be displayed, add a content query webpart and   open its property by edit mode. In the query part -Select the picture library you created as image source and in the presentation - select the newly configure content type and filter order. You can check this article for the details). After this you can now see the images lined up on you page. 
  5.  Now add a content editor webpart and set the source to slider.html from the document library where you uploaded the attached files.

Script files to Download 

PS: You can have different sliding styles with slider1.html . I have used images of size 950 * 240. So if you have different image size, you can change it in the style sheet and slider.html. Feel free to post me any query or comments. Thanks to both articles for providing such a beautiful articles.


Happy Browsing!
Relax..

Tuesday, April 1, 2014

SharePoint 2013/2010 : Export site url , request access email, site owner in to text file using PowerShell Script

 Run the below PS script using admin mode.

 #Pulls site url and request access email and writes out to output.txt

Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | Format-Table -Wrap -AutoSize -Property url,Owner,SecondaryContact,RequestAccessEmail | Out-String -Width 1000 | Out-File -FilePath SiteDetails.txt

#Pulls site url, owner and secondary owner and writes out to output.txt

Get-SPSite -Limit ALL | Format-Table -Wrap -AutoSize -Property url,Owner,SecondaryContact,RequestAccessEmail | Out-String -Width 1000 | Out-File -FilePath SiteDetails.txt

Article Source



Happy Browsing!
Relax..

SharePoint 2013/2010 : Export in to Excel - People and Group

Steps to export the people and group from your site
1. Get the list ID of the group whcih you want to export. To do this, go to People and group and select the group , then go to its setting. Copy the heightened portion from the URL as shown listedit.aspx?List=cf5tea84-e6c7-4be3-95f6-f55b8555bb11

2. Apped the copied List ID from above text to this URL:
 https://SiteCollectionURL/_vti_bin/owssvr.dll?Using=_layouts/query.iqy&List=cf5tae84-e6c7-4be3-95f6-f55b8555bb11

3. Copy and paste the URL formed into your explorer.  Bingo! your people list is in excel now!

(I'm not sure easy way to pull back the people entry back from excel after updating. Will add here once I get the solution.)




Happy Browsing!
Relax..

SharePoint - iFrame inside the page gives error while displaying the webpart page as source the page (cross domain), try this

 


Add this tag in the master page and you are done!

Text:
WebPartPages:AllowFraming ID="AllowFraming1" runat="server"



Happy Browsing!
Relax..

Apply SharePoint 2013 Theme to SiteCollection and its sub site using PowerShell Script


//Add the snapin for the power shell
Add-PSSnapin "microsoft.sharepoint.powershell"



//Set the site collection URL where the theme has to be applied
$url = "Site Collection URL"
$web = Get-SPWeb $URL

//Select the pallet color file,  if you do not have create one from this link.
$file = $web.GetFile($web.ServerRelativeUrl + "/_catalogs/theme/15/MyTheme01.spcolor")

$theme = [Microsoft.SharePoint.Utilities.SPTheme]::Open("MyTheme", $file)
$theme.ApplyTo($web,$true)
$site = Get-SPSite -Identity $url
Write-Host "RootWeb Theme: " + $site.RootWeb.ThemedCssFolderUrl
foreach ($web in $site.AllWebs) {
Write-Host "Web Title: " $web.Title
$web.AllowUnsafeUpdates=$true;
  Write-Host "Web Theme CSS: " $web.ThemeCssUrl
Write-Host "Web Theme: " $web.ThemedCssFolderUrl
$web.ThemedCssFolderUrl = $site.RootWeb.ThemedCssFolderUrl
Write-Host "Web Theme: " $web.ThemedCssFolderUrl
$web.Update()
$web.AllowUnsafeUpdates=$false;
$web.Dispose()
}
$site.Dispose();


PS: The above code is tested in my development server and it runs perfect for SharePoint 2013 and its the risk of the users to run the code in their environment. So run at your own risk! :)

Happy Browsing!
Relax..

SharePoint 2010 Custom Error Page using HTML


Steps to set the custom HTML error page for the SharePoint 2010

1. Prepare your HTML error message page/file and place it in the hive folder ( I'm using a sub folder here 14/CustomError) in the web front end server
2. Open the PowerShell in the administator mode and run the below command.(in all the web front end server)
Set-SPCustomLayoutsPage -Identity Error -RelativePath /_layouts/14/CustomError/error.html -WebApplication  http://sharepointsitecollectionurl


For see the error (Enabling Error Details)
Web.Config >> Enable stack trace ( true) and custom error mode = Off


And this script will not run on the SharePoint 2013 as the error pages are given directly in the Site Collection pages library.

PS: The above code is tested in my development server and it runs perfect for SharePoint 2010 and its the risk of the users to run the code in their environment. So run at your own risk!

More on this http://technet.microsoft.com/en-us/library/ff607768.aspx

Happy Browsing!
Relax..

 Rotating Banner or Slideshow -Free Javascript for Standalone page

A easy and free approach for the rotating banner or images or div that can be used to decorate the home pages of your website.  It has been tested and works in latest versions of all browsers.

For the code, please click here.

Please see this post for free sample and code: http://blog.crondesign.com/2012/01/free-javascript-for-rotating-website.html 

Happy Browsing!
Relax..

SharePoint 2013 - Hide Root Node Link in Global Navigation using CSS

To hide the root node in the global navigation, simply add this style in your content editor or in your main style sheet and its ready to go!
Style Code


.ms-core-listMenu-horizontalBox LI.static > A {
    DISPLAY: none !important
}
.ms-core-listMenu-horizontalBox LI.static > UL A {
    DISPLAY: block !important
}

Before

After 



Happy Browsing!
Relax..

SharePoint : Tabbed Menu using Page Layout

A beautiful article to show the page layout that is fully compatible with  SharePoint 2013 . Simply upload it to the master page gallery, and you're good to go.

Example :
Source: https://sharepointtabs.codeplex.com

Happy Browsing!
Relax..