Foros‎ > ‎

Sharepoint

Sharepoint server Low Disc space

publicado a la‎(s)‎ 14 jun. 2016 6:18 por Ignacio Gonzalez

Step #1: Do the usual stuff first, delete files you don’t need. Running the Disk Cleanup Tool is a good start.

Step #2: Go to central admin, and decrease the # of days to store the log files.

  • In central admin, go to monitoring
  • Go to reporting\Configure diagnostic logging.
  • In the Trace Log section, in the Number of days to store log files box, type in a smaller number – I usually am happy with the last 20 mins of logs or so :)
  • Go to 14\Logs and delete all the files in there. Don’t delete the “LOGS” directory.

Step #3: All those managed services that the farm wizard created – well they use disk space, in the form of databases generally. Not just disk space, they also take CPU cycles. Delete the services you are not using.

Step #4: (THE BEST WAY) Compact databases, login to SQL Server management studio with a user that has sysadmin rights, and run the following script -

  1: DECLARE @DB VARCHAR(255)
  2: DECLARE C CURSOR FOR
  3: SELECT NAME FROM SYS.DATABASES WHERE IS_READ_ONLY=0 AND STATE=0
  4:   AND NAME NOT IN ('master','model','tempdb','msdb')
  5: OPEN C
  6: FETCH C INTO @DB
  7: WHILE @@FETCH_STATUS=0
  8: BEGIN
  9:   EXEC SP_DBOPTION @DB,'trunc. log on chkpt.','true' 
 10:   DBCC SHRINKDATABASE (@DB)
 11:   FETCH NEXT FROM C INTO @DB
 12: END
 13: CLOSE C
 14: DEALLOCATE C

Enjoy all that extra disk space.

Create list from list template - powershell command

publicado a la‎(s)‎ 4 feb. 2016 13:23 por Ignacio Gonzalez

$web = Get-SPWeb "http://site/myWeb/"
$site = Get-SPSite "http://site"
$listTemplates = $site.GetCustomListTemplates($web)
$list =  $listTemplates["TemplateName"]
$web.Lists.Add("List Name", "Description", $list)

Remove invalid Characters from search results - Sharepoint 2013

publicado a la‎(s)‎ 28 ene. 2016 11:53 por Ignacio Gonzalez

Open the display template with sharepoint designer in "Master Pages > Display Templates > Item_Site.html "


Modify it adding the following Script:

<!--#_
ctx.OnPostRender = function() {

 var textValue = document.getElementById('Groups');

   if (textValue != null)
   {
   
    textValue.innerHTML = textValue.innerHTML.replace( /’/g,'´').replace( /€/g,'').replace( /‹/g,'').replace( /â/g,'');
    
   }

};
_#-->

Disable all day event in Calendar list - Disable List fields

publicado a la‎(s)‎ 28 jul. 2015 8:20 por Ignacio Gonzalez

Add into content editor in new form page, and edit form page

<script type="text/javascript">
function HideField(title){
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].innerHTML == title || el.childNodes[j].nodeValue == title)
            { 
                var elRow = el.parentNode.parentNode ;
                elRow.style.display = "none"; //and hide the row
                foundField = true ;
                break;
            }
        }        
    }
    if(foundField)
        break ;
}
}

HideField("All Day Event");
HideField("Recurrence") ;
HideField("Workspace") ;
</script>

Getting SharePoint List items with SharePoint’s REST API in JavaScript

publicado a la‎(s)‎ 28 jul. 2015 8:19 por Ignacio Gonzalez

BY GREG OSTROWSKI ON 10-22-2014 2:07 PM

In my past few SharePoint projects, I’ve been tasked with creating custom JavaScript web parts to display and/or edit list items. When I first had to figure this out, it wasn’t particularly straight forward and basic. While SharePoint gives multiple options on how to use their lists, I was looking for the right one for me. SharePoint 2013 was able to provide me with  a REST API I could call with jQuery ajax requests, and this was exactly what I wanted. 

In my example, I'm accessing a generic task list and outputting the results into a table. I filter my query to grab tasks only assigned to the currently logged in user and only tasks that have not yet been completed. SharePoint's REST API lets us add these filters in our request. The results are given to us as a JSON object, which we can then loop through and insert into a table. I also used a modular pattern to structure my code.

On initialization, we need to know who the user is so we can get them their personalized tasks. SharePoint has some code for us that does exactly this.

Once we know our user's ID, we can generate our REST request. _spPageContextInfo is a SharePoint object that gives us useful information about the page and site we're on, including the base URL of our site.

After successfully getting our list information, we just need to loop through our data, put it in a table, and then insert into our predefined container element. jQuery helps make this an easy process.

Look at my follow up blog to learn how to use this same method to update your items and save the updated list information with REST API calls.

/* Requires jQuery */

var Module = {} || Module;

Module.GetTasks = (function () {
    var pub = {},
        _userId,            //userID of current user
        _tasks = [],        //List of our tasks
        _options = {
            listName: "Tasks",                  //Name of list we want
            container: "#TaskListContainer",    //id of html element we're rendering our list of tasks in
        };

    //Module Initializer
    pub.init = function () {
        var clientContext = new SP.ClientContext.get_current();
        _userId = clientContext.get_web().get_currentUser();
        clientContext.load(_userId);
        clientContext.executeQueryAsync(getUserInfo, _onQueryFailed);
       
    };


    //Once we have our userId, we make Asyncronous call to get our list defined by _options.listName
    function getUserInfo() {
        _userId = _userId.get_id();

        getSpecifiedList(_options.listName, _userId);
    }

    //Makes a REST Call to grab a specified List with items assigned to the userId. Items must not have a status of 'Completed'
    function getSpecifiedList(listName, userId) {
        var url = _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('" + listName + "')/items?$filter=(AssignedTo eq '" + userId + "') and (Status ne 'Completed')";
        $.ajax({
            url: url,
            type: "GET",
            headers: {
                "accept": "application/json;odata=verbose",
            },
            success: function (results) { createTaskView(results, listName); },
            error: function (error) { 
                console.log("Error in getting List: " + listName); 
                $(_options.container).html("Error retrieving your " + listName + ".");
            }
        });
    }

    //Upon Receiving Task List data, we set as our module's _task list .
    //We then iterate through each task and add to a table which we then insert into our container defined in _options.container
    function createTaskView(results, listName) {
        _tasks = results.d.results;

        var table = $("<table style='width: 100%;'>" +
                            "<tr>" +
                                "<th>Title</th>" +
                                "<th>Due Date</th>" +
                                "<th>Status</th>" +
                            "</tr>" +
                      "</table>");
        $.each(_tasks, function (index, task) {
            var tr = '<tr>' +
                       '<td>' + task.Title + '</td>' +
                       '<td>' + new Date(item.DueDate).toLocaleDateString() + '</td>' +
                       '<td>' + task.Status + '</td>' +
                    '</tr>';
            table.append(tr);
        });
        $(_options.container).html(table);
    }

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

    return pub;
}());

$(document).ready(function () {
    //must wait for SP scripts as we require them in our code
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
        Module.GetTasks.init();
    });
});

SharePoint 2013 sticky footer

publicado a la‎(s)‎ 13 jul. 2015 15:39 por Ignacio Gonzalez   [ actualizado el 17 jul. 2015 12:37 ]

Adding a footer to SharePoint masterpage may be a bit tricky, since SharePoint automatically recalculates height and scrolling properties of some default div containers on page load. Today I will show how to add a so called "sticky footer" to a SharePoint masterpage using Javascript. The sticky footer will be displayed always at the bottom of the page, even if there is little content. We will base on the SharePoint 2013 "Seattle" masterpage.

Masterpage structure changes

First we need to add a footer container (div) to our masterpage, that will contain the footer content. We add this at the end of the default "s4-workspace" div, right after the "s4-bodyContainer" div:
1
2
3
4
5
6
<div id="s4-workspace" class="ms-core-overlay">
    <div id="s4-bodyContainer">
    (...)
    </div>
    <div id="footer">Your footer content goes here</div>
</div>
Now you need to populate your footer with content and set its CSS properties e.g. height.

Javascript code

Now that we have our footer container let's position it with some javascript code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// generic function for resizing elements within their containers
function adjustContainerHeightToObject(container, content, offset){
 var container = $(container);
 var content = $(content, container);
 if (container.height() > content.height()) {
  content.height(container.height() + offset);
 }
}
 
// specific function for resizing the s4-body container
function resizeMainContent(){
    // as offset we provide the negative value of the height of our footer
    adjustContainerHeightToObject('#s4-workspace', '#s4-bodyContainer', -50); // for footer with 50px height
}
 
// call resize function on page load
_spBodyOnLoadFunctionNames.push("resizeMainContent");

_spBodyOnLoadFunctionNames.push() vs. $(document).ready()

Notice that instead of using regular jQuery ready() event we are using SharePoint's custom mechanism for calling function after the page loads. This will ensure that all SharePoint resizing code has already executed when calling our function.




MODIFIED SOLUTION
UPDATE WITH LIST VIEW ISSUE (When open items JS, modifiy the s4-bodyContainer height)


   // generic function for resizing elements within their containers
function adjustContainerHeightToObject(container, content, offset){
 var container = $(container);
 var content = $(content, container);
  var s4BodyContainer = document.getElementById('s4-bodyContainer');
 if (container.height() > content.height()) {
 content.css("min-height",container.height() + offset + "px");
 }
}
 
// specific function for resizing the s4-body container
function resizeMainContent(){
    // as offset we provide the negative value of the height of our footer
    adjustContainerHeightToObject('#s4-workspace', '#s4-bodyContainer', -51); // for footer with 50px height
}
 
// call resize function on page load
_spBodyOnLoadFunctionNames.push("resizeMainContent");



//HIDE ON DIALOG MODE
       if (currentURL.indexOf("IsDlg=1") >= 0 || currentURL.indexOf("isdlg=1") >= 0)    {  
    var objFooter = document.getElementById('footer');
    if (objFooter.complete) {
        objFooter.style.display = 'none';            
        }
       
}

SPO 2013: Stylesheet links and SharePoint:CssRegistration stopped working properly

publicado a la‎(s)‎ 10 jul. 2015 9:00 por Ignacio Gonzalez

Use: ms-design-css-conversion="no"

<link href="../../Style%20Library/CSS/Principal.css" type="text/css" rel="stylesheet" ms-design-css-conversion="no"/>

Famous SharePoint URLs & Locations

publicado a la‎(s)‎ 21 may. 2015 13:03 por Ignacio Gonzalez

Some times you want to jump right to a specific system list, page or go to the edit mode in a SharePoint site. I wanted to list all the famous urls I used for the past years and ask you to tell me about any other ones you know to add it here in the list. Other have already contributed a bunch :)

(Remember for SharePoint 2013 you might want to add "15" after "/_layouts/" but if you don't SharePoint will take care of that for you) .. Also some of these are turned off on Office 365 SharePoint online.

 

Sandboxed Solution Gallery:

/_catalogs/solutions/Forms/AllItems.aspx

 

Workflow history hidden list:

/lists/Workflow History

 

Filter toolbar for Lists and libraries (Added by Asimaili):

?Filter=1


Site usage page (Added by @Dnyag):

/_layouts/usage.aspx

 

Site content and structure  page (Added by @Dnyag):

/_layouts/sitemanger.aspx

 

Site settings page (Added by Aowworld):

/_layouts/settings.aspx

 

View all site content page (Site content) (Added by Aowworld):

/_layouts/viewlsts.aspx

 

Manage site collection features - CASE SENSITIVE -  (Added by Vardhaman):

/_layouts/ManageFeatures.aspx?Scope=Site

 

Manage site features (Added by Vardhaman):

/_layouts/ManageFeatures.aspx

 

 Get the version of the SharePoint server (Patch level) (Added by: John Liu):

 /_vti_pvt/Service.cnf

 

Web Part Maintenance Page (Added by: Ricky):

?Contents=1

 

Show Page in Dialog View (Added by:Ricky):

?isdlg=1

 

Application page for registering SharePoint apps

/_layouts/15/appregnew.aspx

 

Save Site as a template

/_layouts/savetmpl.aspx

 

Sign in as a different user

/_layouts/closeConnection.aspx?loginasanotheruser=true

 

Enable SharePoint designer

/_layouts/SharePointDesignerSettings.aspx

 

Welcome Page (Default page settings)

/_layouts/AreaWelcomePage.aspx

 

Change Site Master Page

/_layouts/ChangeSiteMasterPage.aspx

 

Page Layouts and Site Templates

/_Layouts/AreaTemplateSettings.aspx

 

Master Pages library

/_catalogs/masterpage/Forms/AllItems.aspx

 

User Information List

_catalogs/users/simple.aspx

 

Quick Deploy List

Quick%20Deploy%20Items/AllItems.aspx
 

Open Page in Edit Mode

?ToolPaneView=2

 

Taxonomy Hidden List (MMS)

Lists/TaxonomyHiddenList/AllItems.aspx

 

User Information List:

_catalogs/users/simple.aspx

 

Force displaying the user profile in the site
collection:

/_layouts/userdisp.aspx?id={UserID}&Force=True


Source: http://blogs.msdn.com/b/how24/archive/2013/06/13/save-publishing-site-as-a-template.aspx

SharePoint: Overcome the Top Navigation bar issue with Touch Devices, Phones - Mobile

publicado a la‎(s)‎ 8 abr. 2015 13:42 por Ignacio Gonzalez

 SharePoint: Overcome the Top Navigation bar issue with Touch Devices, Phones ... etc

Ever wondered once you have deployed your Portal on an Environment, how would it look like when using touch tablets (iPad, Windows 8 Tablets, Android Tablets...etc) ?

Well, one of the main issues that I faced was the Top Navigation Bar Hovering Sub-Menus.

By design, SharePoint OOB Top Navigation Menu works as follows (dah !!):
1- You hover you mouse on the Parent Menu
2- While hovering, you can see the Sub-Menu Items Drop down
3- By a Mouse Click, You choose the sub-menu you want, to be redirected to the desired URL

But when using a touch devices, once you point your finger on the parent menu, you are redirected to your destination directly, without even the chance to see the sub-menu items dropdown (Damn!!! :D)

So, a couple of searches on the internet, and I was able to inject a JQuery Script in my master-page to avoid this, and at the same time, it works as expected with normal PCs (mouse hovering and such)

So here you go:

First: Add a reference to JQuery (I'm using Google's API):

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>

Then Start Writing the following Script (covering almost all devices I can find/think of):

<script>
//Ahmed Medhat: Upadting SharePoint OOB Hovering for iPad/iDevices/Windows-RT
jQuery(document).ready(function() {    
if((navigator.userAgent.match(/iPhone/i)) || 
(navigator.userAgent.match(/iPod/i)) || 
(navigator.userAgent.match(/iPad/i)) || 
(navigator.userAgent.match(/Android/i)) ||
(navigator.userAgent.match(/blackberry/i)) || 
(navigator.userAgent.match(/1000/i)) || 
(navigator.userAgent.match(/9000/i)) || 
(navigator.userAgent.match(/m180/i)) || 
(navigator.userAgent.match(/t849/i)) || 
(navigator.userAgent.match(/i987/i)) || 
(navigator.userAgent.match(/tablet/i)) || 
(navigator.userAgent.match(/p100/i)) ||
(navigator.userAgent.match(/i800/i)) ||
navigator.userAgent == "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; ARM; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)" ||
navigator.userAgent == "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)")
{
jQuery("a.dynamic-children").click(function(e) {
  if($(this).attr('select') == null)
  {
$(this).attr('select','true');
if(e.preventDefault){
        e.preventDefault();
    }
else{
//e.stopImmediatePropagation();
//e.returnValue = false;
//e.cancelBubble=true;
setTimeout(function(){},3000);
}
  }
  else if ($(this).attr('select') == 'true')
  {
$(this).removeAttr('select');
  var location = $(this).attr("href");
    window.location = location;
  }
});

jQuery("a.dynamic-children").mouseout(function() {
  $(this).removeAttr('select');
});

}});

</script>

To properly, understand the Script, let me take it step by step:

1- Checking the Current User Agent (Device Accessing the Portal):


<script>
//Ahmed Medhat: Upadting SharePoint OOB Hovering for iPad/iDevices/Windows-RT
jQuery(document).ready(function() {    
if((navigator.userAgent.match(/iPhone/i)) || 
(navigator.userAgent.match(/iPod/i)) || 
(navigator.userAgent.match(/iPad/i)) || 
(navigator.userAgent.match(/Android/i)) ||
(navigator.userAgent.match(/blackberry/i)) || 
(navigator.userAgent.match(/1000/i)) || 
(navigator.userAgent.match(/9000/i)) || 
(navigator.userAgent.match(/m180/i)) || 
(navigator.userAgent.match(/t849/i)) || 
(navigator.userAgent.match(/i987/i)) || 
(navigator.userAgent.match(/tablet/i)) || 
(navigator.userAgent.match(/p100/i)) ||
(navigator.userAgent.match(/i800/i)) ||
navigator.userAgent == "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; ARM; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)" ||
navigator.userAgent == "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)")

As you can see, I'm just checking if the user agent matches any of the above devices, such as "iPhone/i" or "iPad/i" which is the agent's name.
As for Windows Surface or Other Windows Tablet Devices, you'll need to match with that user  agent name "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)".
but be careful to change the compatibility version of the IE you specified in your masterpage (I added IE 8 & 10 for an example)

Once the code detects that you are using one of these browsers, then you can get the current pressed menu item by referring its href class "dynamic-children" using jQuery

jQuery("a.dynamic-children").click(function(e) {


2- Checking if the current pressed parent menu has an attribute called "select" (which of course there isn't):

if($(this).attr('select') == null)

if not, then add the select attribute to that parent menu

$(this).attr('select','true');

After adding this attribute, I need to prevent the default action of the menu item from redirecting you to its specified URL

if(e.preventDefault){ //Works only with other browsers than IE :(
         e.preventDefault();
     }

The above action works only with browsers other than IE, so to overcome that using an IE browser, I just thought to add a three seconds halt for the menu item before it redirects the user to its destination URL

else{
//e.stopImmediatePropagation(); //Didn't Work :(
//e.returnValue = false; //Didn't Work, although lot of articles said it would
//e.cancelBubble=true; //Didn't Work :(
setTimeout(function(){},3000); //My Solution :D
}

3- Now, Check if the User already pressed on the parent menu item and decides once again to press on it to go to planned destination URL

else if ($(this).attr('select') == 'true')
  {
$(this).removeAttr('select');
  var location = $(this).attr("href");
    window.location = location; //Simulating the normal redirection behavior of the parent menu
  }

4- Finally, When the User has a menu item already opened, and decides to click on another parent menu item, so we need to switch the "select" attribute from the old parent menu to the new pressed parent menu item. So simply remove the "select" attribute from the old parent menu and when the user presses on a new parent menu, it will start over through the code and check if that menu item has the "select" attribute or not (check step 1).

jQuery("a.dynamic-children").mouseout(function() {
  $(this).removeAttr('select');
});

And Voila !!!!

For the IE browser part, I know it not the best solution, but its the most acceptable solution I found till now, maybe someone could provide something better ;)


Note: If you need to use as well touch phones and experience the portal in that design not in default SharePoint mobile redirect view, then:

  • Add the below segment to the "configuration/system.web" section of your web application's web.config
  • The segment to add:
    • <browserCaps><result type=”System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”/><filter>isMobileDevice=false</filter></browserCaps>

Missing pageStatusBar - DeltaPageStatusBar - Sharepoint 2013

publicado a la‎(s)‎ 28 mar. 2015 4:19 por Ignacio Gonzalez

Add to your MP:

<!--MS:<SharePoint:AjaxDelta id="DeltaPageStatusBar" BlockElement="true" runat="server">-->

      <div id="pageStatusBar"></div>
   <!--ME:</SharePoint:AjaxDelta>-->

1-10 of 45