Monday, December 21, 2015

Auto complete feature in SharePoint 2013 list column using SPServices in SharePoint 2013

In this post we will discuss how we can achieve auto complete feature for a column in SharePoint 2013 list using jQuery and SPServices. Here I am have custom list name as "MyProjects" which has one column name as Title and it has data looks like below :


Then I have another list which has two columns one is the default Title column and other one column name is "MyProjectName". And I want the auto complete feature should display the values in the MyProjectName column from the above "MyProjectLists" list (Title column).

For this I have added the below piece of code in the SharePoint list new form in a script editor web part.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>
    <script type="text/javascript">
       
        $(document).ready(function ()
        {
                $().SPServices.SPAutocomplete({
                sourceList:"MyProjectsList",
                sourceColumn: "Title",
                columnName:"MyProjectName",
                ignoreCase: true,
                numChars: 1,
                slideDownSpeed: 'fast'
        });
    });
    </script>

Now if I will start typing something then the auto complete feature will display the related values.


Friday, September 25, 2015

SharePoint 2013 Interview Questions : Part 1-4

Below are some quick answered SharePoint 2013 Interview Questions:-
1) Describe the Cloud App Model.
The Cloud App Model enables you to create apps. Apps for SharePoint are self-contained pieces of functionality that extend the capabilities of a SharePoint website.
2) What is an App in its most basic form?
A web application that is registered with SharePoint using an app manifest.
3) What is an app manifest?
An app manifest is an XML file that declares the basic properties of the app along with where the app will run and what to do when the app is started.
4) Where can the code for an app run?
SharePoint-hosted apps, Provider-hosted and auto hosted apps, Apps that have a mix of components in SharePoint and in the cloud.
5) How does an app communicate with SharePoint?
a. REST and JavaScript APIs
b. Managed APIs (.NET)
6) How can the app authenticate to SharePoint?
a. Inside SharePoint
b. In the cloud
7) How are apps distributed?
Apps for SharePoint are distributed as an app package.
8) What are some options for app publishing?
a. Public SharePoint app store
b. Organization’s app catalog
9) What is OData?
The Open Data protocol (OData) lets you access a data source, such as a database, by browsing to a specially constructed URL.
10) What is the primary benefit of OData?
Simplified approach for connecting to and working with data sources that are hosted within an organization.
11) What technologies does OData use?
a. HTTP
b. Atom
c. JavaScript Object Notation (JSON)
12) What is OAuth?
An open protocol for authorization.
13) What does OAuth enable?
Secure authorization from desktop and web applications in a simple and standard way.
14) What is OAuth used?
To authorize requests by an app for SharePoint, to access SharePoint resources on behalf of a user and to authenticate apps in the Office Store, an app catalog, or a developer tenant.
15) What is an Access token?
Access tokens are issued by the OAuth security token service (STS) to request app permissions.
16) What are the three types of authorization policies?
user-only policy, user + app policy, or app-only policy.
17) How does an app for SharePoint requests permissions to access SharePoint resources?
An app for SharePoint requests the permissions that it needs during installation from the user who is installing it and then the developer of an app must request, through the app manifest file, the permissions an app needs.
18) Which office technology can be used to build SharePoint 2013 workflows?
Visio 2013 includes a SharePoint 2013 Workflow template that can be used.
19) What is a WebInfo object?
From REST resources it is an object that contains the scalar properties of the site, but that does not include any associated entity sets such as list collections or field collections.
20) What is Client-side rendering?
Client-side rendering provides a mechanism that you can use to produce your own output for a set of controls that are hosted in a SharePoint page.
21) What are remote event receivers?
Remote event receivers handle events that occur to an item in the app, such as a list, a list item, or a web.
22) What is Microsoft Push Notification Service?
Using the Microsoft Push Notification Service (MPNS), Windows Phone apps can receive notifications through the Internet of events triggered on Microsoft SharePoint Server.
23) What are some benefits of the new Geolocation field type?
Allows incorporation of location, maps, and proximity search features into their web and mobile apps and solutions.
24) What is a display template in terms of SharePoint search?
Display templates define the visual layout and behavior of a result type by using HTML, CSS, and JavaScript.
25) What are result types in terms of SharePoint search?
Result types define how to display a set of search results.
26) What is Keyword Query Language (KQL)?
Allows you to specify the search terms or property restrictions that are passed directly to the search service.
27) What is FAST Query Language (FQL)?
FQL is a structured query language that supports advanced query operators.
28) What is meant by a fully declarative workflow?
The workflow is described (literally) in XAML and then executed interpretively at run time.
29) What is the Design Manager?
The Design Manager enables a step-by-step approach for creating design assets that you can use to brand sites.
30) What is the Snippet Gallery?
Allows a user to select a component, configure its properties and update the snippet, copy the HTML snippet that’s generated, and paste that HTML snippet into your HTML file.
31) What are Device channels?
Device channels define channels for one or more devices allowing finely-tuned control over how mobile users experience your site.
32) What is managed navigation?
Managed navigation is the taxonomy-based alternative to the traditional SharePoint navigation feature.
33) What are Catalogs?
Allow you to incorporate lists into your publishing sites.
34)What is cross-site publishing?
Enables you to reuse content across multiple site collections.
35) What is the Machine Translation Service?
The Machine Translation Service is a new service application in SharePoint 2013 that provides automatic machine translation of files and sites.

Tuesday, August 18, 2015

Create a State Machine workflow in SharePoint 2013 designer workflow

One of the most important feature can be achieved in SharePoint 2013 designer workflow as we can achieve state machine workflow in SP2013 designer but not in SP2010/2007.

Below are the steps to create a state machine workflow:
1. Create a workflow in designer
2. Design the workflow by putting stages to the designer.
3. Add your custom actions into it as per below snap.
4. After completion of designing the workflow, publish it.
5. Test with associated list or library.
About these ads
Occasionally, some of your visitors may see an advertisement here.

Adding Button in calculated Field in SharePoint 2013

Add button in the calculated field in SharePoint 2013 list definition:
<Field Name=”Accept” ID=”{1F7328C7-D7F0-4B94-BB15-01859CD28CF2}” DisplayName=”AcceptorDecline” Type=”Calculated” ResultType=”Number” ReadOnly=”TRUE” JSLink=”/_layouts/15/CCAR.SP.Common.Lists/UserRecertification/UserRecertificationScripts.js”>
<Formula>
=”&lt;div id=’divAccept’&gt; &lt;input type=’button’ name=’btnAccept’ id=’btnAccept’ onclick=””UpdateApproveorDecline(‘”&amp;[URID]&amp;”‘,’Yes’)”” value=’Approve’/&gt;
&lt;input type=’button’ name=’btnDecline’ id=’btnDecline’ onclick=””UpdateApproveorDecline(‘”&amp;[URID]&amp;”‘,’No’)”” value=’Decline’ /&gt;&lt;/div&gt;”
</Formula>
<FieldRefs>
<FieldRef Name=”URID” />
</FieldRefs>
</Field>
//UserRecertificationScripts.js code
function UpdateApproveorDecline(URID, ApproveorDecline) {
if (!isEmpty(URID))
{
GetListID(URID, ApproveorDecline);
}
}
function GetListID(URID, ApproveorDecline)
{
if (!isEmpty(URID))
{
var clientContext = new SP.ClientContext.get_current();
if (!isEmpty(clientContext))
{
var webSite = clientContext.get_web();
var list = webSite.get_lists().getByTitle(‘User Recertification’);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<View><Query><Where><Eq><FieldRef Name=\’URID\’/><Value Type=\’Text\’>’ + URID + ‘</Value></Eq></Where></Query></View>’);
this.collListItem = list.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, function (sender, args)
{
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext())
{
//Get the current item then get the item ID
var currentItem = listItemEnumerator.get_current();
//Getting the values to pass to the popup function
var itemid = currentItem.get_item(“ID”);
UpdateListItem(itemid,ApproveorDecline)
}
}),
Function.createDelegate(this, OnLoadFailed));
}
}
}
function UpdateListItem(itemid, ApproveorDecline)
{
if (!isEmpty(itemid))
{
var clientContext = new SP.ClientContext.get_current();
if (!isEmpty(clientContext))
{
var webSite = clientContext.get_web();
var list = webSite.get_lists().getByTitle(‘User Recertification’);
this.oListItem = list.getItemById(itemid);
oListItem.set_item(‘Accept_x002f_Decline’, ApproveorDecline);
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, function (sender, args)
{
alert(“Accept/Decline set to ” + ApproveorDecline);
}),
Function.createDelegate(this, OnLoadFailed));
}
}
}
function OnLoadFailed(sender, args) {
//Displays an error in case the request fails
alert(“Request Failed: JSOM Error, ” + args.get_message() + ‘\n’ + args.get_stackTrace());
}

Missing “Save Site as Template” for Publishing Sites in SharePoint 2013?

Summary : Missing “Save Site as Template” for Publishing Sites in SharePoint 2013?, How to Save Publishing Sites as Template in SharePoint 2013,Workaround to Save Site as Template in Publishing Site Template.
One of the old and well known workarounds for this was to directly navigate to “_layouts/savetmpl.aspx” application page and save the site Template. This workaround however does not work as expected in SharePoint 2013 sites.
In a Typical SharePoint 2013 Publishing Site, if you try to navigate to “_layouts/savetmpl.aspx” you would get the below error –
“The “Save site as template” action is not supported on this site.”
SharePoint 2013 Save site as template action is not supported on this site.
The url “_layouts/savetmpl.aspx” failed on the Publishing site because by default, in at Typical Publishing Site in SharePoint 2013, “SaveSiteAsTemplateEnabled” is set as “false”. Setting this switch as true would re-enable us to use “_layouts/savetmpl.aspx” to save a Typical Publishing Site in SharePoint 2013.
The easiest way to set SaveSiteAsTemplateEnabled as true is by using Site options in SharePoint Designer 2013.
Lets look the Steps –
1. Open you Publishing Site in SharePoint Designer 2013.
2. In SharePoint Designer, under Sites tab select “Site Options” (see screen below)
SharePoint 2013 Site Options
3. Find “SaveSiteAsTemplateEnabled” in Site Properties (see below).
SharePoint 2013 Save site as temple
4. Next change this setting to “true”.
SharePoint 2013 Set as True
Apply the Setting once done.
5. Now in your Publishing site navigate to “http://sitename/_layouts/15/savetmpl.aspx” and you would see the old Save Site as Template Page as expected.
SharePoint 2013 Save as Template

How to Save Site as Template in SharePoint 2013

In SharePoint 2013 Sites are Saved as Template in the same way as in earlier versions but there are some steps that you need to consider before moving forward.
Important things to know about Saving Sites as Template –
  • In SharePoint 2013, by default, you Cannot Save a Publishing Site (or a Site with Publishing feature activated) as a Site Template.This however Can be done using a workaround (i.e. using _layouts/savetmpl.aspx url). See this detailed post onHow to Save Publishing Site as Template in SharePoint 2013
  • As in SharePoint 2010 Saving Sites as Template does not generate a .stp file, it gets saved as a .wsp in Solutions gallery.
  • When Saving a Site as Template the WSP generated is temporarily saved in thec:\temp or in c:\windows\tempfolder and later in the solution gallery on SharePoint. Make sure that the App pool account has Full permissions toc:\tempand c:\windows\temp folder.
  • You Cannot Create a Subsite based on a Site Template that was Created in SharePoint 2010. You will need to recreate the site template in the 2013.
So here is the Step-by-Step process to Save a Site as Template in SharePoint 2013.
Steps –
1. Open a Team Site that you need to Save as Template and Navigate to Site Settings ->Under “Site Actions”  select “Save Site as Template”.
If you do not see Save Site as Template and you get “The “Save site as template” action is not supported on this site.” See this post How to Save Publishing Site as Template in SharePoint 2013
2. Next in the Save as Template Page enter Template Name and Description.Click Ok.
3. Next, you would see a Operation Successful message with a link to “solutions gallery”.
4. If you Navigate to the solutions gallery you can see that the CustomTemplate is added to the library.Next we will create a site using this Template.
5. To Create a Site\Subsite from a Template Navigate to “Site Contents” -> new subsite (towards the bottom).


The New “Project Sites” in SharePoint 2013

Summary : The New “Project Sites” in SharePoint 2013,How to Create “Project Sites” in SharePoint 2013,Difference between Project Site and a Team Site.
SharePoint 2013 has new Project Sites Template that provides Out-of-box webparts and pages that facilitate Project Managers and Teams work efficiently. Lets look at the features of this site template.
How to Create a Project Site –  To Create a Project site you can use the Out-of-boxProjects template available. Navigate to Site Contents -> new Subsites and select aProjects template.
Once it gets Created you can see that Projects Sites contain Getting Started tiles, a Project Summary\Timeline webpart,a NewsFeed and a Documents webparts.
Project Sites SharePoint 2013Project Summary or Timeline WebPart – The Timeline WebPart in project sites is tied to “Tasks” list by default but you can edit the properties of this webpart and select any other task list to show even task list in other site or subsite as well.To add tasks to timeline click on Edit the task list and add items to the the Tasks list.
Timeline SharePoint 2013
The Project Summary webpart on the main page gets the Tasks added to it.It also displays the Days left and
Timeline WebPart SharePoint 2013
There is not much difference between a Project Site and a Team Site but here are few minor ones for our readers reference
Project Sites
* Project Sites has “Project Functionality” Site Feature activate by default.
* A Project Summary WebPart is added to the main page by default.
* Project Sites had “Task” list added to it by default.
Team Sites
* Team Sites has “Wiki Page Home Page” Site Feature activate by default. “Project Functionality” Feature is not active by default.
* Project Summary WebPart or any Timeline webpart can be added to the site.
* Team Sites had “Team Task” list added to it by default.

The object has been updated by another user since it was last fetched.

Sometimes when we are updating Content Types programmatically, we might come across the following exception:
“The object has been updated by another user since it was last fetched”
I got this exception for the following code in my Feature Receiver’s FeatureActivated method:
private SPContentType EnsureContentType(SPWeb web, string contentTypeName)
{
    SPContentType contentType = web.ContentTypes[contentTypeName];
    if (contentType == null)
    {
        SPContentType parentContentType = web.ContentTypes[SPBuiltInContentTypeId.Item];
        contentType = new SPContentType(parentContentType, web.ContentTypes, contentTypeName);
        contentType = web.ContentTypes.Add(contentType);
    }

    contentType.FieldLinks[SPBuiltInFieldId.Title].Hidden = true;
    contentType.Description = contentTypeName;
    contentType.Group = "Test";
    contentType.Update();
}

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPSite site = properties.Feature.Parent as SPSite;
    using (SPWeb web = site.OpenWeb())
    {
        SPContentType contentType = EnsureContentType(web, "My Content Type");
        Guid guid = "CBE1FD3E-351B-43B8-94A6-33868300FA6E"; //Some valid Guid
        if (contentType.FieldLinks[guid] != null)
        {
            contentType.FieldLinks.Delete(guid);
            contentType.Update(true); //This is the line that throws exception
        }
    }
}
This exception occurs randomly. The same piece of code is working fine in a different place. The only way that I found to fix this problem is to instantiate new SPSite and SPWeb objects, instead of using SPContext.Current.Web or SPWeb from properties object.
So, I changed my code as shown below to get rid of the exception.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPSite site = properties.Feature.Parent as SPSite;
    using (SPWeb web = site.OpenWeb())
    {
        SPContentType contentType = EnsureContentType(web, "My Content Type");
        Guid guid = "CBE1FD3E-351B-43B8-94A6-33868300FA6E"; //Some valid Guid
        //Instantiating new SPSite and SPWeb objects
        using (SPSite newSite = new SPSite(web.Site.ID))
        {
            using (SPWeb newWeb = newSite.OpenWeb(web.ID))
            {
                contentType = newWeb.ContentTypes[contentType.Id];
                if (contentType.FieldLinks[guid] != null)
                {
                    contentType.FieldLinks.Delete(guid);
                    contentType.Update(true); //No more exceptions
                }
            }
        }
    }
}
Note: You might also face this problem if you are creating/updating Content Types using xml files. There is a Version attribute in your Elements.xml file that needs to be removed to fix the same problem. For more information, you can refer to this blogwhere the problem is explained in detail.
That’s it guys……a small post on a problem that can be a huge pain.

How to Create a Lists and Libraries in SharePoint 2013 the Old way

In SharePoint 2013 the Concept of “Apps” is a little Confusing. Its not your Phone Apps for sure so what is it? In simple words, some of the SharePoint Components like Lists, Libraries,Sandbox or  Custom Applications,few Features like Event Receivers(remote) or Field types (based on existing field types) are termed as “Apps”. So now if someone want to say “Add a new List” to SharePoint, they should probably say “Add a List App” to SharePoint instead.
In SharePoint 2013 you can add a new List using the new “Add an app” option or you can directly switch to the old Create View that you had in SharePoint 2010.Lets see the Old way first
Create a SharePoint 2013 List From Create Page(Old way)
In your Browser Open the URL“https://siteUrl/_layouts/15/create.aspx” to go to the old Create View.

Select Custom List to Create a new List.
Add Name and Description and Click Create.
Create List with Add an app –

How to get team site lists and templates in SharePoint 2013 publishing site

Team site lists and templates like, survey list, announcement list, task list, promoted links list won’t be available by default for a SharePoint 2013 publishing Site. To enable these list templates and functionalities in SharePoint 2013 publishing site, navigate to site settings, and select Manage Site Features available under “Site Actions” category. Locate the “Team Collaboration Lists” feature is the list of available features and activate it. This will include all the list templates related to team site to a SharePoint Site

Friday, July 31, 2015

Vertical Promoted Links in SharePoint 2013

SharePoint 2013 has nice little tiles called Promoted Links to link to stuff all over your sites.  However, they all display horizontally when you add them to your page. Silly Microsoft for not providing us the option to list them horizontallyor vertically in the first place – but thank you SharePoint community for providing the work-around,

<style type="text/css">
 .ms-promlink-body {width: 170px !important; }
 .ms-promlink-header {display: none;}


 </style>

To make one set of links vertical and the other horizontal :
<style type=”text/css”>
#msozonecell_webpartwpq6 .ms-promlink-body {width: 170px }
#msozonecell_webpartwpq6 .ms-promlink-header {display: none}
</style>
Refer this link : 
http://veroniquepalmer.com/2014/08/14/vertical-promoted-links-in-sharepoint-2013/

Tuesday, January 13, 2015

What is distributed cache Service in SharePoint 2013

The Distributed Cache service provides caching functionality to features in SharePoint Server 2013. The Distributed Cache service is either required by or improves performance of the following features:
  • Authentication
  • Newsfeeds
  • OneNote client access
  • Security Trimming
  • Page load performance
The microblog features and feeds rely on the Distributed Cache to store data for very fast retrieval across all entities. The Distributed Cache service is built on Windows Server AppFabric, which implements the AppFabric Caching service. Windows Server AppFabric installs with the prerequisites for SharePoint Server 2013.

Any server in the farm running the Distributed Cache service is known as a cache host. A cache cluster is the group of all cache hosts in a SharePoint Server 2013 farm. A cache host joins a cache cluster when a new application server running the Distributed Cache service is added to the farm. When using a cache cluster, the Distributed Cache spans all application servers and creates one cache in the server farm. The total cache size is the sum of the memory allocated to the Distributed Cache service on each of the cache hosts.
The Distributed Cache service can run in dedicated or collocated mode. When running in dedicated mode, the Distributed Cache service is started and all other services are stopped on the server. In collocated mode, the Distributed Cache service is running along with other services on the server.
Some benefits of using microblog features, feeds, and the Distributed Cache include the following:
  • Allows users to stay in touch with individuals and specific groups of people over time and distance.
  • Allows users to stay informed about what's going in the organization.
  • The focus of the interactions is around people or teams, and not so much the topic being discussed.
  • It is difficult to keep track of activities related to documents, discussions, and lists in SharePoint without manually visiting the item regularly. Feeds collect and deliver information to users that they would otherwise have to spend time searching for.
  • The feed gives users a single place where they can stay up-to-date with all of the content and people they work with.
  • Allows quick conversations to take place
MS although strongly recommends that following services should not be run on the server where Distributed Cache Service is running –

SQL Server
Search Service
Excel Service
Project Server

Reference:
http://technet.microsoft.com/library/jj219700(office.15).aspx