Wednesday, April 15, 2015

How to kill installed windows service which is stuck at starting state

One day I have installed the windows service using developer command line tool. Service is installed successfully. After that I tried to start the service from command prompt, suddenly it got stuck at starting.

At that time, I thought to kill the process using command line because I cannot reboot the server.

Step 1: First of all you need to find the service name which has stuck at starting state

Navigate to Run >> type Services.msc

It will open the Services window, find the installed windows service which has stuck at starting state and click on it and note down the name of service.

Step 2: Now open the command prompt and type the below command

> sc queryex ServiceName

It will result as below and note down the PID.



Step 3: From command prompt type the below command to kill the service using PID

>taskkill /f /pid 11140


Enjoy SharePoint!!!

How to get image URL using JSOM in SharePoint 2013

Use below code to get the image URL from the Image field which has type as Hyperlink or Picture in SharePoint custom list.

var user;
var clientContext;
var lstItem;
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadImage);

function loadImage() {
DisplayImage() ;
}
function DisplayImage () {

     clientContext = new SP.ClientContext();
     var groupCollection = clientContext.get_web().get_siteGroups();
     user = clientContext.get_web().get_currentUser();
     clientContext.load(user);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {
var lst = clientContext.get_web().get_lists().getByTitle(“ListName”);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View> <Query> <Where><Eq><FieldRef Name=\ID\' /><Value Type=\'Text\'>1</Value></Eq></Where> </Query> <ViewFields><FieldRef Name=\'Image\' /><FieldRef Name=\'ID\' /></ViewFields> </View>');
    lstItem= lst.getItems(camlQuery);
    clientContext.load(lstItem);
    clientContext.executeQueryAsync(onSuccess, onQueryFailed);
}
function onSuccess()
{
            var ListEnum = lstItem.getEnumerator();
           
            while(ListEnum.moveNext()){
                        var objListItem=ListEnum.get_current();
                        document.getElementById("ImageID").src= objListItem.get_item("Image").get_url();
                        }
}
function onQueryFailed(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}


Enjoy SharePoint!!!

Friday, February 13, 2015

Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID

In SharePoint Provider hosted app, I got below error while deploying the app in development environment.

"Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID"

To overcome this issue, you need to change the major or minor version in AppManifest.xml file of Provider hosted app and it should work.

Enjoy SharePoint!!!

Wednesday, February 4, 2015

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

When I was tried to access SharePoint 2013 application, I got below error. It gave me the same error while accessing the Central Administration too.

This error occurs due to SQL Server service is not started.

To start the service Go to Start >> Run >> Services.msc >> SQL Server (MSSQLServer)
Click on Start

Navigate to the browser and refresh the page, SharePoint 2013 web application is working fine.

Enjoy SharePoint!!!

Tuesday, February 3, 2015

Route document using Content Organizer in SharePoint based on metadata

SharePoint provides out of box feature to automatically route document specific libraries or folder is called Content Organizer. It can be used to manage document library constantly. Content organizer is automatically move document to specific target location based on specified metadata.

Using this feature end user do not to remember where to upload the document. It will automatically route the document based on defined custom settings & rules or applying proper manage metadata. This is a very powerful feature of SharePoint to organize the documents consistently.

With Content Organizer, you can automatically route document from one site collection to another site collection. Make sure you should have Content Organizer feature is activated in another site collection. 

You can route content or document within the farm using content organizer.

Content organizer will work only with content types that are inherited from document content type.

How to use content organizer in site
1. Activate Content Organizer feature
2. Create library or folder to route document
3. Configure content organizer settings
4. Create content organizer rule
5. Upload document in Drop off Library
6. Verify the routed document in specified library or folder

Step 1: Activate Content Organizer feature
  • Navigate to SharePoint 2013 Web Application
  • Navigate to Site Settings >> Site Actions >> Manage Site Features
  • Click on Activate button to enable Content Organizer feature from the list of features

  • Once Content Organizer activated it will add Content Organizer settings and Content Organizer Rules options inside Site Settings >> Site Administration
  • Also creates new document library called Drop off Library. You can see it in quick launch bar of home page.



Step 2: Create library or folder to route document
  • Click on Site Contents from quick launch or from clicking on gear icon from top right corner of the screen
  • Click on Add an app
  • Click on Document library app
  • Give name to document library as "SampleDocLib"
  • Click on Create

Step 3: Configure content organizer settings
  • Navigate to Site Settings >> Site Administration >> Content Organizer Settings
  • Select the check box for Redirect Users to the Drop Off library to route user to upload the document in this library and route it based on defined rules.
  • If you would like to route content or document to another site’s library or folder then select the Allow rule to specify another site as a target location under Send to Another Site section.




Step 4: Create content organizer rule
  • Navigate to Site Settings >> Site Administration >> Content Organizer Rules
  • Click on New Item to add new rule
  • Provide rule name as Sample Rule
  • Select Content type group as Document Content Type and type as Document in Submission’s Content type section. You can also add custom content type that must be inherited from document content type.
  • In Conditions section, select property as Title and operator as contains all of and value as Sample in property-based conditions.
  • Select newly created document library named “SampleDocLib” in target location section by clicking on browse button.
  • Click OK.



  • Once you add new rule it will create new item in content organizer rule. You can create many rules and define the priority of rules as well.


Step 5: Upload document in Drop off Library
  • Click on Drop Off Library from quick launch in left side navigation
  • Click on New Document
  • Select the document and give title values as “Sample HTML Design file”
  • Click Submit


  • If content organizer rule named Sample Rule is match with the metadata "Sample" which we added for uploaded document then it routes the document to "SampleDocLib" library


  • And if Sample rule is not match then it will upload the document in Drop off library itself.



  • Later on site administrator will take decision to move the document from Drop off library
Step 6: Verify the routed document in specified library or folder
  • Navigate to document library named "SampleDocLib"
  • You will see the routed document in the library as we have mentioned the meta data as "Sample".


Enjoy SharePoint!!!

Thursday, January 15, 2015

Indexed column in SharePoint List

Indexed column in SharePoint list is used to improve performance of query to work with large list efficiently.

You can create index on single column (Specify primary column for index) or specify compound index on two columns (Specify primary & secondary column for index).

SharePoint list instance support a maximum of 20 indices.

Not all the field types can participate in composite index.

When you create an indexed column, it requires extra storage space to maintain it and also adds unnecessary overhead. So you should create index only to columns that will be used in filtering view on list.

Managed metadata navigation and filtering require indexing column on list.       





Indexed column also affect the throttling for list that contains large amount of items.

Suppose you build query that returns first 100 items from non-indexed Title column with sort, then query would have to scan all the items from list in content database to define the sort order for first 100 items. Due to that query become throttled. To avoid such issue, create index on Title column to returns the first 100 sorted items instead of scanning all the list items from content database.

Not all column types can be indexed. Following table shows supported and unsupported column types for indexing in list.


Supported column types
Unsupported column types
Single line of text
Multiple lines of text
Choice field having single value
Hyperlink or Picture
Number
Calculated field
Date/Time
Yes/No
Lookup (Single value)
Custom field type
Person or group (single value)
External data
Currency

Title (only in list)

Managed metadata


How to create index column in list:

1. Navigate to SharePoint List >> List Settings
2. Click on Indexed Columns

3. Click on Create Index link
4. Select Primary column as Title from the drop down list and keep secondary column as blank if we do not require any compound index column.

5. Click on Create button to generate new index column and will display as below. You can also edit the indexed column by clicking on it.
 
Enjoy SharePoint!!!