Showing posts with label Document Library. Show all posts
Showing posts with label Document Library. Show all posts

Tuesday, January 3, 2017

How to skip an edit form after uploading a single document in SP 2013

How to skip an edit form after uploading a single document in SP 2013

I would like to set all document properties programmatically inside the event handler. i do not manage to skip an edit form after the document is uloaded.

Solution :

Javascript solution for sharepoint 2013


In SP.UI.Dialog, there is a function to close a dialog : commonModalDialogClose
Takes two parameters, commonModalDialogClose(dialogResult, returnValue)
dialogResult is an enum (here is an extract from SP.UI.Dialog.js :
SP.UI.DialogResult.prototype = {
    invalid: -1,
    cancel: 0,
    OK: 1
};
Solution : When using the upload.aspx page, you will be redirected to the EditForm.aspxincluding a QueryString parameter, Mode, that will be tagged as Upload. Using that information, the dialog can be closed. The QueryString parameter is retrieved using the GetUrlKeyValueSharePoint native function.
GetUrlKeyValue(keyName, bNoDecode, url, bCaseInsensitive)
add the following into the library EditForm.aspx using JSLink
(function (){
    var mode = GetUrlKeyValue("Mode", false, window.location.href, true);

    if (mode == "Upload")
    {
        //commonModalDialogClose(dialogresult, resultValue)
        //dialog result : -1 = invalid; 0 = cancel; 1 = ok
        //resultValue : text
        commonModalDialogClose(0, null);
    }
})();
Hope this help,

Wednesday, December 2, 2015

Add Full Breadcrumbs to SharePoint Document Library

Add Full Breadcrumbs to SharePoint Document Library


Inexcusably, SharePoint has no true breadcrumb navigation. In document libraries, navigating up and down the folder hierarchy is a painful series of pageloads. Fortunately, there are options.
If you have access to the server, you can create a custom code solution in SharePoint Designer or Visual Studio and serve it up. But before devoting resources to a server configuration change and all that entails, there’s a client side option that’s much easier to implement.

As a user of document libraries with folders up to a dozen levels deep, this is much appreciated.  The best part about this solution is the simplicity, it’s pure javascript and CSS, with no dependencies like jQuery or other outside libraries.  This means it works in IE8+, and creates no additional load on the server.
On note I will make, be sure the “title” option is set for the document library web part, which is not the default in SharePoint 2013. If it is not showing, the breadcrumb will be hidden. It’s also simple enough to modify the javascript to draw the breadcrumb to another element elsewhere on the page.

/*
* Adds a breadcrumb to "Document Library" Web Parts
* Copyright 29/11/2013 - Alexis Nominé - MIT Licence
* Mdified by Oumaima Achkari - Adaptation to SharePoint 2013 - 02/12/2015
*/

_spBodyOnLoadFunctionNames.push("doBreadCrumbs");//execute after DOM loaded

function doBreadCrumbs(){

                // Get 'RootFolder' value in URL
                var rootStr = getUrlParam('RootFolder');   
                if (rootStr != '') {
                               // Get all links in WebParts titles (IE8+)
                               var webpartHeaders = document.querySelectorAll('.ms-webpart-titleText a');
                               // For each link
                               for(var i = 0; i < webpartHeaders.length; i++){
                                               var webpartHeader = webpartHeaders[i];
                                               // Get link target
                                               var link = decodeURIComponent(webpartHeader.getAttribute('href'));
                                               // If target contains 'RootFolder' value, then we have our Web Part.
                                               // Let's generate our breadcrumb
                                               var pathname = window.location.pathname;
                                               if(rootStr.indexOf(link) != -1){
                                                   var path = rootStr.replace(link, ''); // Folder path, relative to Doc Lib
                                                    var basepath = rootStr.replace(path, ''); // Doc Lib path
                                                              
                                                    var breadcrumb = '<span class="breadcrumb">';
                                                     var LibraryName = $(".ms-webpart-titleText").text();
                                                    breadcrumb += '<a href="' + location.pathname + '">'+ LibraryName  +'</a>'; // link to base page
                                                              
                                                               // Create link for each sub-folder
                                                               var folders = path.split('/');
                                                              
                                                               for(var i = 1; i < folders.length; i++){
                                                                              var currentfolder = folders[i];
                                                              
                                                                              basepath += "/" + currentfolder;
                                                                              // Replace 'RootFolder' value in URL without touching any other variables(orderby, etc.)
                                                                              var folderlink = window.location.search.replace('RootFolder=' + encodeURIComponent(rootStr), 'RootFolder=' + encodeURIComponent(basepath));
                                                                              breadcrumb += ' &gt; <a href="'+ pathname+'?RootFolder=' +encodeURIComponent(basepath)+ '">' + currentfolder  + '</a>';
                                                                              //breadcrumb += ' &gt; <a href="Formations.aspx?RootFolder=/Formations/'+encodeURIComponent(currentfolder)+ '" ">' + currentfolder  + '</a>';
                                                               }
                                                               breadcrumb += '</span>';
                                                              
                                                               // Insert breadcrumb
                                                               //webpartHeader.getElementsByClassName("span")[0].innerHTML += breadcrumb;
                                                               $(".js-webpart-titleCell").append(breadcrumb);
                                                               //document.getElementById("WebPartTitleWPQ2").innerHTML += breadcrumb;

                                               }
                               }
                }
}

/* Get param value from query string */
function getUrlParam(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));}

Wednesday, October 21, 2015

Can’t Delete Empty Document Library Folder

Can’t Delete Empty Document Library Folder

When is an empty folder not an empty folder?  When it’s located on SharePoint of course!  The folder may appear empty in SharePoint, in Explorer view and in SharePoint Designer.  Attempting to delete the folder results in the following message:
“The file is currently checked out or locked for editing by another user.”
Say what?!
More than likely, the document library requires check out and may have versioning enabled.  Someone uploaded files to the document library, but never checked them in.  So, there are files in the folder, but only visible to the individual that uploaded them.  To locate these files:
  • Open the document library
  • Go to the document library settings
  • Select “Manage files which have no checked in version”
All the files that have never been checked in will appear.  Select the files  and then click “Take Ownership of Selection”.  The files will now be visible in SharePoint and can be deleted or checked in.  Deleting the files will allow the folder to be deleted.

Hope this help,
Oumaima

Tuesday, May 5, 2015

How to Apply Metadata Navigation Filtering in SharePoint 2013

How to Apply Metadata Navigation Filtering in SharePoint 2013

In this post I will show how to set up Metadata Navigation Filtering in Share Point 2013. This is one of the most powerful features available in helping users quickly find what they need without writing any code, it really just needs to be turned on and configured.

I start on the Home Page of the Site which is at the top level site of the site collection created and configured in the previous posts. Metadata Navigation and Filtering is a Site Feature that has to be activated for this to work.
1
112.png
On the right side I click on the site Actions Gear and go to Site Settings where I will activate the Site Feature, Metadata Navigation and Filtering.
2
212.png

3
312.png

This site feature is not activated on the Team Site Template so I click Activate.
4
411.png

When I see the blue icon that says Active, I know I’m good to go.
5
56.png
I click the link in the Quick Launch bar to get to the gdpByStateReports Library I configured in previous posts.
6
62.png

I click the Library Tab.
7
72.png

I click the Library Settings Icon.
8
82.png

We are going to use th Metadata navigation settings that is now available on the Library to pivot on these two Metadata columns.
9
92.png
This will allow users to find reports immediately based on Metadata regardless of which older they are in.
10
102.png
I click the Metadata navigation settings link. This link was not available on the Library Settings page until the Metadata Navigation and Filtering Site Feature was activated.
11
113.png

This is the Metadata navigation settings page.
Here we see two main areas: Configure Navigation Hierarchies and Configure Key Filters. These two work hand-in-hand to basically give users multiple levels of filtering in an amazing UI that gets added just below the Quick Launch Bar. (I highlighted some areas of particular importance).
The Navigation Hierarchies and only use: Content Type, Single-value Choice fields, or Managed Metadata Fields and the Key Filters can only use Content Type, Choice Field, Managed Metadata Field, Person or Group Field, Date and Time Field, or Number Field. Between the two if you do some planning with this in mind you can create very powerful User Interfaces out of the box.
We are going to use the StateOfOrigin and YearOfReport choice fields in Both areas and we are going to leave the Folders in the Navigation Hierarchy Fields.
12
122.png
To configure the controls, you select the columns on the left side and click the Add button which moves them over to the right side. When you are done your page should look like the figure above. When it’s ready you can click OK at the bottom of the page. Clicking OK Not Shown.
13
132.png
Now that its all configured we can click the gdpByStateReports link in the breadcrumb where we will see our amazing U.I.
14
142.png

Just below the Quick Launch, Share Point has added the Navigation Hierarchy and Key Filter Controls. I will start by clicking the State Of Origin in the top control.
15
152.png

This expands to show the available fields (the options in choice column) I click on AR (Arkansas)
16
162.png
Immediately the content area of the web page shows all the reports that have the value AR in the StateOfOrigin column, REGARDLESS of which folder they reside in!
17
172.png
With the state of Arkansas Selected in the Hierarchy control (AR) I go to the key Filters click the drop down menu for YearOfReport, You may have noticed that the StateOfOrigin Drop down disappeared because I already filtered on that column.
18
182.png
I select 2010 and click Apply. My results are immediately apparent. I now see all reports for the State of Arkansas from the year 2010, regardless of which Folder the result set resides in.
19
192.png
If I click the link to go back to the Document Library I can see that it resets my controls to their original state an returns the YearOfReport drop down to the U.I.
That’s it! Users can now quickly and efficiently parse through folders with out of the box functionality.

Wednesday, July 16, 2014

Missing "Destination Folder" on upload document form

Missing “Destination folder” on upload document form

When uploading documents into a document library with folders, you normally see the following screen:

Problem On one of our sites the Destination Folder was not available. After some investigating I found that the site where it didn’t work, was created using the “Blank site” template. 
Solution Since we used the “Blank site” template, some features do not get activated by default.
I found out that the feature that is responsible for the “Destination Folder” is the “Metadata Navigation and Filtering”feature.
image
After activating the solution, the Destination Folder became available. Note that if you turn this feature off, existing libraries will be able to select a destination folder, as where newly created document libraries will not be able to use this feature.

Gruop items by folder name

Group Items on Their Folder Name Inside a SharePoint Library


As you probably will know, folders could not be used in views to group documents. You could only group documents on their metadata.
Group Documents
Group Documents
A possible solution could be to add a new metadata field to the content type and manually add the folder name as the metadata value. It is very easy to add and requires no custom development, but it requires an extra manual step from the document creator.
This manual step can also be automated by a SharePoint 2010 Document library functionality called Column default value settings. It can be found on the document library settings page under the General settings section.
The Column default value settings enable you to define a default value for a metadata column per folder.
Default column value
Default column value

Approach

  • Go to the document library settings;
  • Create a new column called: Folder name (Single line of text);
  • Click on Column default value settings under the General settings section;
    Culumn default value settings
    Culumn default value settings
  • On the left side you will see your folders, and on the right site the columns for which you could give up a default value;
    Folders, columns
    Folders, columns
  • Click on the folder name, and after that on the column name;
    Default column value
    Default column value
  • Click Use this default value, and fill in the folder value and click OK;
  • Repeat this process for each folder.
Now when you upload a document to a folder, the Folder name column will automatically get the default value.
To prevent users being able to fill in their own value, you could hide the Folder name columnfrom the new and edit forms.
Hidde column from forms
Hidde column from forms

Result

Group by on folder name
Group by on folder name

Attention: SharePoint Foundation

The Column default value functionality is not available in SharePoint Foundation.

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing I have an ordinary Wiki Page, also tried making an Article...