How to check-in multiple files at once


SCENARIO:

When you have a mandatory column in document library and when you upload multiple files and folders in it using “Open with explorer” option, all the files either within or without folders will be checked out by default.

Checked Out Files

When you try to check-in the file, it will prompt you to fill out all the required properties before checking in the file.

SOLUTION:

How to fill out the properties for multiple files(including the files within folders):

  • Click on Library in the ribbon and click “Create View” under Manage Views
  • Choose Datasheet view, give a name(say, Properties view) and check the boxes under Columns for Type, Name and the mandatory columns
  • Expand the folder and choose “Show all items without folders”and click OK button.

Folder Options

  • Now, fill out the values for mandatory column in properties view

Properties View

  • Stop editing this list

How to Check-in the files:

  • Go to Properties view and switch to Standard view
  • Select all the documents using ‘Tick Mark” behind Name column
  • Click on Files tab in the ribbon and select “Check In” under “Open & Check Out”

Check In.png

Alternative ways to check in multiple files in Publishing sites:

If you have at least edit permission in a publishing site, you can use the below method:

  • Go to Site Settings and click on “Content and Structure” under Site Administration
  • Change the view from “Default View” to “Checked Out To Me” as depicted below:

Content and Structure - Checked Out to Me.png

  • Select all the documents, go to Actions and select “Check In” as shown below

Content and Structure - Check In.png

That’s it!

SharePoint REST API results in browsers


Rest api results for SharePoint lists can be seen in Google Chrome in xml format.

What if you don’t have Chrome and still interested in viewing results ?

To view results in IE:

Feed in IE

  • Go to Settings and click on Internet Options

IE options

  • Click on Settings under Feeds and Web Slices in Content tab and uncheck the turn on feed reading view box.

Settings

  • You will see the results in Xml format as shown below:

xml

To view results in Mozilla Firefox:

  • Open Firefox and type the rest url. You will see the same feeds page as IE

Firefox feed

Result in firefox

Advantages of viewing results in browsers:

  • You can immediately verify the rest operation results
  • You can find the column name to use it in rest operation

Exclude AllItems.aspx from Search Results in Content Search Web Part


When I was working with Content Search web part in one of my SharePoint sites, I experienced a problem where the search result for list items is displayed along with list views.
In this article, I will show you how to remove the list views in CSWP search results.
For better understanding, consider a list, EMPINFO from which you want to show the items in CSWP. To show specific list items, you might have carried out the below steps

  • Edit the CSWP and click on Change query

  • Choose Documents (System) in Select a query
  •  Choose Specify a URL and enter the list URL for Restrict by app

  • Switch to Advanced mode and remove the highlighted file extension query text.

  • You can see AllItems.aspx view along with the list items in search results.

To remove the view, you can follow any one of the below step:

  • Select “Only return items “ in keyword filter and click on “Add Keyword Filter”
  •  Just append [contentclass:STS_ListItem] after Path in Query text

Upgrading SharePoint App


Whenever you make changes and redeploy the app, data that were created previously by the app will be lost. To make changes in the app without losing the data, you need to upgrade the app.

Let us see how to upgrade the app:

  • Open AppManifest.xml and increment the version number by 1 whenever a change is made
  • In my case, version is 1.0.0.2. Hence I am changing it to 1.0.0.3 and publishing the app as shown below:

Publishing app

  • Click on Finish in Publish summary.

Publish summary

  • Explorer window opens as depicted below:

Published app version

  • Copy the location of the file and go to the developer site
  • You can see the list of apps in App Testing. Select the app and click on upgrade an app

Upgrade

  • Click on Upload and browse the file from copied location

Upgrade - Upload

  • Click on Upgrade

Upgrad - Complete

  • You can see the upgrade progress as shown below:

Upgradeinprogress

  • Once upgraded, the version is changed to 1.0.0.3 and if you check for the previous data, it actually exists.

That’s it!

Reference: http://www.c-sharpcorner.com/article/upgrade-sharepoint-hosted-add-insapps-in-sharepoint-2013/

 

PART 2 : SharePoint-Hosted App


Have you read PART 1? Cool. Continue reading how to create an app in host web.

Let us see the same create operation for better understanding. We need two URLS for this:

  • HostURL
  • AppWebURL

To retrieve the URLS, QueryStringParameter() is generally used. But this does not work in all the cases especially when we move from one page to another in app web. So, let’s use the below one:

  • appWebUrl = window.location.protocol+”//”+window.location.host+_spPageContextInfo.webServerRelativeUrl;
  • hostUrl = _spPageContextInfo.siteAbsoluteUrl;

To change the context site from app web to other sites, AppContextSite() is used. To change the current context(i.e, app web) to host web, pass it as
var appctx = new SP.AppContextSite(ctx, hostUrl);

Let’s combine all these with previous code. Here you go:

var appWebUrl;
var hostUrl;
$(document).ready(function ()
 {
appWebUrl = window.location.protocol+"//"+window.location.host+_spPageContextInfo.webServerRelativeUrl;
hostUrl = _spPageContextInfo.siteAbsoluteUrl;
 $("#create").on('click', function ()
 {
                createList();
  });
});
//create List
function createList()
 {
    var listTitle = $("#listName").val();
    var ctx = new SP.ClientContext(appWebUrl);
    var appctx = new SP.AppContextSite(ctx, hostUrl);
    var oweb = appctx.get_web();
    var listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title(listTitle);
    listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
    oweb.get_lists().add(listCreationInfo);
    ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQuerySucceeded() 
{
    alert("List Created");
}
function onQueryFailed(sender, args) {
    alert("Operation Failed" +"\n"+ args.get_message());
}

After deploying the app, when you create the list, the below error is shown

Access Denied for Host Web

  • This is because to access or create resource in host web, we need to give FULL CONTROL permission for web and list. To give permission, open AppManifest.xml, move to permission tab and give the permission as shown below:

Fullconrol Permission

  • Now when you deploy it, you will get the below page:

Trust the app

  • Click on trust and create a list using the app. List is created in the host web and can be seen in the site contents page.

If you have noted that when you deployed the app again after making some changes, the data created previously were lost. Continue reading the next article, Upgrading SharePoint app to learn how to deploy the app without losing the data.

PART 1: SharePoint-Hosted App


Apps for SharePoint are also called as SharePoint Add-ins. In SharePoint 2013, everything is considered as an app. Lists, libraries are all called as apps. Apps can be hosted

  • In SharePoint farm (SharePoint-hosted)
  • In separate server(Provider-hosted)
  • In cloud(Auto-hosted)

SharePoint-Hosted App:

It includes only SharePoint components. SharePoint Site where the app is installed is called Host web. All the resources such as list, libraries are in isolated sub site called App web.

Let us create a SharePoint-hosted app to create a list in SharePoint On-Premise environment.

  • Run Visual Studio as administrator and click on File->New->Project

New Project

  • Select Apps for SharePoint 2013 and give a name(say, createListinHost) and hit ok button

Host

  • Next, Specify the site url ( say,Developer site), select the type as SharePoint Hosted and click on Finish

SharePoint Hosted app

  • App is created and default aspx page is shown.

Default aspx

  • Replace the highlighted code with the below one to create a textbox and button for create operation.

<label for=”listName”>List Name to be created</label>
<input type=”text” id=”listName” Placeholder=”Enter the listname”/>
<input type=”button” id=”create” value=”Create”/>

  • Branding(Optional):
    • You can change the title of the page in
      <asp:Content ContentPlaceHolderID=”PlaceHolderPageTitleInTitleArea” runat=”server”> List Creation </asp:Content
    • You change the icon for app in AppManifest.xml. Open AppManifest and change the image for Icon. Image should be of 96*96 pixel

App Icon

  • To insert create functionality in this app, expand Scripts, open App.js and insert the below code:
$(document).ready(function () 
{ 
    $("#create").on('click', function () {
                createList();
    });
});
//create List
function createList()
{
    var listTitle = $("#listName").val();
    var ctx = SP.ClientContext.get_current();
    var oweb = ctx.get_web();
    var listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title(listTitle);
    listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
    oweb.get_lists().add(listCreationInfo);
    ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQuerySucceeded() {
    alert("List Created");
}
function onQueryFailed(sender, args) {
    alert("Operation Failed" +"\n"+ args.get_message());
}
  • Press F5 or click on Solution->Deploy to deploy the code. Default aspx page will be opened in browser. If not go to the site->Site Contents and click on the app, “createListinHost”

App in Site Contents

  • Create a list say, Sample

 

Below page is shown where you can see that sample list created under “createListinHost”

Sample list settings

Site lists and libraries

Now, question arises. Should all the resources reside in app web only? What If I need to create a resource or access a resource that is in host web? Can I do it? Yes, you can create and access resources in host web. Continue Reading in PART 2

Challenges faced after exporting Excel data to SharePoint


In previous article, we have seen how to connect to SharePoint site from excel for exporting data. Today, let us see the challenges faced in SharePoint after exporting the data.

  1. Number columns with greater than or equal to 4 digits in excel – Lets consider, Application ID column with value 20158 for better understanding. As number column in excel are associated with number column in SharePoint, they are displayed with commas as 20,158
    • To remove the commas, never try converting it into Single line of text in SharePoint because it will be converted into exponential form as 20+158e
    • If you would like to show them without commas, create a calculated column with the below formula:
    • =TEXT([Application ID], “0”)
    • By using this formula, Commas will be removed but calculated columns will be shown only in display form
    • So, before exporting it is recommended to convert number field with more than 4 digits in excel to text column as to associate it with single line of text. Now, to prevent the users from entering number in Single line of text field, follow the below steps:
    • Go to List->List settings and click on Application ID column
    • It takes us to Change Column page for Application ID where we need to enter the below formula in Data validation section and click ok
    • =ISNUMBER([Application ID]+0)
  2. Person or Group column in SharePoint for user names like Manager in excelAs text columns are associated with  Single line of text, they cannot be converted to Person or group column. What if we need to use People Picker(Person or Group) for user names. Below is a small workaround which will be useful if there are thousands of items.
    •  If number of items is less, create a person or group column, open edit form of each item and copy paste the value manually from single line of text to Person or group field. When there are large number of items(say 2000), create below two columns in SharePoint:
    • Flag – Yes/No type
    • Mgr – Person or group type in SharePoint
    • Go to SharePoint designer and create a workflow which should run whenever an item is changed
    • Create the below step:
      • If flag equals Yes
      • set Mgr(Person or group column) to Manager(Single line of text)
    • Now, go to Datasheet view of the list and simply select Yes and drag the Yes value till the last item
    • Advantage: It reduces the time than doing it manually
    • Disadvantages:
      • Workflow fails when exact match is not found meaning either the person has left the organization or their Id in active directory is changed
      • We need to manually fill for those items where workflow has failed
      • Remove the workflow from the list once all the user names are copied to Person or group column
  3. Missing “Add new item” link in SharePoint 2010 – To overcome this, create a Standard view and set it as default view

If the above post is helpful, do not forget to like my article and rate it.

Exporting Excel table to SharePoint


SharePoint is used everywhere especially for document and content management. Nowadays, data that were stored in excel are being moved to SharePoint , thus making the ease of access and management of data. To facilitate this, SharePoint has an app(list) called “Import Spreadsheet” as shown below:

import-spreadsheet creating-sp-list
import-dialog

This approach is known to everyone where we select Import Spreadsheet list, provide a name and description, browse the excel file, select the range of cells to be imported. But only few of us know how to connect from excel to SharePoint. This article will cover the later approach. Let us see how to do.

  • Open desired sheet in excel and select the range of cells to be moved to SharePoint(both rows and columns)
  • Click on Insert->Table. In create table dialog box, check the range and hit ok

create-table

  • Now, you will be able to see Design Tab in the ribbon.
  • Under External Table Data section, click on Export->Export Table to SharePoint List

design-and-export

  • In Export table step 1 dialog box, give the address of SharePoint site, check create a read-only connection box, provide a name and description for SharePoint list and click Next

step-1

  • “Create a read only connection to the new SharePoint list” box is used to keep the excel table up-to-date with the changes made in SharePoint list. This is only one way meaning, you cannot update changes from excel to SharePoint once it is exported. When you check the box, it creates two columns in the excel table
    • Item Type  – Item/Folder
    • Path – folder path for a list item
  • In step 2, we can verify the data types of excel columns associated with data types in SharePoint. For example, Student Name of type text in excel is associated with Single line of Text in SharePoint. After verification, click Finish button.

step-2

  • Table has been published successfully and two columns(Path and Item Type) are created in excel as said previously

exported-successfully

excel-table
Excel Table

sharepoint-list
SharePoint List
  • To demonstrate the power of “Create a read-only connection to the new SharePoint list”, let us edit the mark of student, Chitra in SharePoint list

edit-in-splist

  • Then go to excel and click Design->Refresh. Excel table is updated as depicted below

autoupdated-excel

  • To remove this read-only connection, click on Design->Unlink

unlink

Advantages:

  • This approach is useful when we need to check the associated datatypes(shown within braces) before exporting data to SharePoint. If we need to change the data type, cancel step 2, change datatype in excel and follow step 1 & 2 again

advantage

  • Creating a read-only connection allows to keep excel report up-to-date rather than often exporting updated data from SharePoint list.

If you found this post useful, please press like button, rate this article and share your comments.

Query Strings in SharePoint


Let us see some of the query strings used in SharePoint:

  • contents=1 ->used to troubleshoot the sharepoint page.When it is appended at the end of the url as:

https://…/sitepages/Home.aspx?contents=1

it takes us to webpart maintenance page where we can find the webpart causing the error by trying to close each one and deleting the problematic webpart

  • IsDlg=1->used to hide the header and quick launch(i.e. chrome).Generally used in SharePoint forms.
  • FilterField1=Gender&FilterValue1=Male(FilterField1=columnname&FilterValue1=columnvalue)->used to filter sharepoint list webpart with the condition, Gender=”Male”
  • FilterName=Hobbies&FilterMultiValue=Painting;Reading(FilterName=columnname&FilterMultiValue=columnvalue1; columnvalue2)->used to filter sharepoint list with multiplevalues in singlecolumn
  • PageView=Shared&ToolPaneView=2->used to show the edit mode of the page, browse and add the webpart
  • PageView=Shared&ToolPaneView=3->used to show the edit mode of the page, search and add the webpart
  • SortField=Hobbies&SortDir=Desc(SortField=ColumnName&SortDir=Desc/Asc) ->used to sort the sharepoint list by Hobbies in Descending order
  • _layouts/viewlsts.aspx -> To go to “All Site Content” Page

Printing Webpart


Let us consider that you have one of the below scenario:

Scenario 1:

You have multiple web parts in a page, say a list and a chart web part and you need to print only chart web part

Scenario 2:

You have an sharepoint list form with quick launch and you need print out without quick launch.

Solution:

  • Go to the desired page and edit it
  • Insert script editor web part and paste the below code or refer the below code in content editor webpart
  • To find the webpart element ID, press F12, point to the webpart and get the ID

<input onclick="javascript:void(PrintWebPart())" type="button" value="Print Web Part"/>

var WebPartElementID = "WebPartWPQ2";
//change the webpart element ID with yours

function PrintWebPart()
{
var bolWebPartFound = false;
if (document.getElementById != null)
{
var PrintingHTML = '\n\n';
if (document.getElementsByTagName != null)
{
var HeadData= document.getElementsByTagName("HEAD");
if (HeadData.length > 0)
PrintingHTML += HeadData[0].innerHTML;
}
PrintingHTML += '\n\n\n';
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
{
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
}
else
{
bolWebPartFound = false;
alert ('Cannot Find Web Part');
}
}
PrintingHTML += '\n\n';
if (bolWebPartFound)
{
var PrintingWindow = window.open("","PrintWebPart", "toolbar,width=800,height=600,scrollbars,resizable,menubar");
PrintingWindow.document.open();
PrintingWindow.document.write(PrintingHTML);
PrintingWindow.print();
}
}