Thursday, 17 November 2016

3rd Level SharePoint SharePoint Navigation in Global Navigation

SharePoint 2013 only supports one level deep on drop downs. If you require the navigation to show 2nd level or 3rd level item under the 2nd level, global navigation will not allow it directly. The other approaches are you do managed navigation. But it has its own limitations listed here.

Resolution:

If you require the navigation to show 2nd level menu, you need to make a very minor tweak to the master page that the site is using.

  1. Using SharePoint Designer (SPD), open the master page being used by the site. In SPD, navigate to _catalogs/masterpage/yourmasterpage.html
  2.  In the master page file, search for SharePoint:AspMenu.
    1. You will more than likely have more than one instance of a menu control.  Look at the IDs to find the right navigation control for what you want to edit.  They are intelligently named, you will be able to sort out which one you need.   For default.master, look for ID=”TopNavigationMenu”.
  3. In the properties for the tag, find MaximumDynamicDisplayLevels=”1″.  Change the number from 1 to 2. (You need to level till you need navigation)
  4. Save the file and publish the master page (do this from SPD, Manage Content and Structure, or the Master Page Gallery).
  5. Refresh your browser.  Now when you mouse over menu, you should see another level of navigation pop up.
  6. If you have more than 2nd level of navigation, you have to first add them separately in global navigation first. Once you save your changes, edit top navigation, drag 2nd level navigation under 1st level navigation.
  7. If you have more than 2 level navigation, you won't be able to drag 3rd level navigation in 2nd level. For that you need to create your custom master page and do that process.

Limitations of Managed Navigation in SharePoint 2013

When SharePoint 2013 came out, one of the most promising features was the Managed Navigation. Configuring Managed Navigation in SharePoint 2013 is straightforward and provides great no-code solution. In this blog, I will walk through some of the major limitations and why you must avoid this solution.
 
1) For each site collection you need separate Term Set.
It is important to note that each term set can be associated with only one site collection at given time. In other words, it requires dedicated copy of term set for each site collection navigation. E.g. If you have 5 site collections, you must have 5 copies of same term set to use for 5 site collections navigation data.

If term set is already configured to use for Site Collection navigation and if you try to reuse same term set in another site collection, SharePoint will throw following warning “The selected term set is already used by another site” 

2) Managed Navigation can’t be secured or targeted to specific group.
 One of the great abilities of Structured Navigation was you can configure audience targeting or secure each menu item for specific audiences or SharePoint security groups. Unfortunately Managed Navigation can’t be secured or targeted to specific security group.

3) Manual Maintenance is still required to update global navigation menu items.
 As we discussed earlier, you must have 1 term set for each site collection. If you have more than 1 site collection, you must have more than 1 term set dedicated to each site collection. To ensure, all the site collection uses same navigation menu items, there are two options available in SharePoint 2013 for replicating term sets. Regardless of which approach you may take, it will require manual maintenance of reconfiguring term sets when you have changes in term set.

4) Managed Navigation doesn’t apply to Sub Sites automatically.
 This is another one of those mind-boggling limitations of Managed Navigation. If you have enabled Managed Navigation at the site collection and while creating sub sites, if you are planning to inherit parent navigation, Managed Navigation doesn’t apply to sub sites automatically. To resolve this peculiar issue, you must open Navigation page from sub site settings page and click “OK” for to take in effect.
   
5) Managed Navigation doesn’t provide open link in new tab.
Structural navigation provide you check box option to open link in new tab. This functionality is not provided in Managed navigation. Though you can overcome this issue with JavaScript patch, you need to put this patch in master page of each site collection to work.

6) Managed Navigation conflict with SharePoint js.
Managed navigation stops working if you explicitly load sp.core.js in your page. The sub level navigation stops populating. I don’t know the strange behavior of it as sp.core.js is SharePoint own js file. 

7) Managed Navigation displays additional home tab. 
This is not though limitation but its annoying for sure. Managed navigation displays first tab with site name additionally. You can't directly change it or hide it. The thing we need to do with it is mostly hide it with javascript and the bad thing is we need to put that in each and every masterpage.

Thursday, 4 August 2016

SharePoint Exceptions : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

Issue: 

I was trying to delete a task when I was encounter with below error:

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

Code Sample:

SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPWeb web = SPContext.Current.Site.AllWebs[new Guid(web guid)]) // this line throws error
                            {
                                SPList taskList = web.Lists[new Guid(list id)];
                                SPListItem _lstItem = taskList.GetItemById(Convert.ToInt32(item id));
                                if (_lstItem != null)
                                {
                                    _lstItem.Delete();
                                }
                                taskList.Update();
                            }                      
                    });

Reason:

From this site I was able to get reason for this error:
When running inside RunWithElevatedPrivileges, if use SPContext.Current.Site object directly, you will not able to get site object.

Solution:

Instead create a new SPSite object, passing in SPContext.Current.Site.Url.

Code Sample:

SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite site = new SPSite(SPContext.Current.Site.Url)) //add this line
                        {
                            using (SPWeb web = site.AllWebs[new Guid(web guid)])
                            {
                                SPList taskList = web.Lists[new Guid(list id)];
                                SPListItem _lstItem = taskList.GetItemById(Convert.ToInt32(item id));
                                if (_lstItem != null)
                                {
                                    _lstItem.Delete();
                                }
                                taskList.Update();
                            }
                        }
                    });

Reference: 
  1. http://sharepoint.stackexchange.com/questions/27462/unable-to-evaluate-expression-because-the-code-is-optimized-or-a-native-frame-is
  2. http://frazzleddad.blogspot.in/2011/03/getting-past-sharepoint-exceptions-with.html

Wednesday, 6 July 2016

IIS/SMTP - emails are stuck in mailroot/Queue

Recently I was working on sending mail using smtp server where I stuck on below error:

IIS/SMTP - emails are stuck in mailroot/Queue

Here are few solution that were tried and might help you:

  • Check password and username in SMTP server
  • Check Pop3 mail setting (require enable) in receiver/ sender mail settings. 
  • SMTP Virtual Server > Properties > Delievery > Outbound Connections. The option for Limit number of connections to was checked and the value was 20. So it was configured to never make any outbound connections, causing the emails to never leave the server. I unchecked the option and restarted the SMTP server and all was well.
  • 'Simple Mail Transfer Protocol (SMTP)' service might be stuck. Try restarting service.
  • If you are using SharePoint, check running jobs (Microsoft incoming mail). If its is stuck, run it manually.
  • Open IIS 6.0. Right click on SMTP Server Properties. Go to delivery tab on Outbound Connections, fill in TCP Port to 25( if its 587).




How to enable pop-ups in Chrome, Firefox, Safari and Internet Explorer

Here are the steps to allow pop up in Chrome, Firefox, Safari and Internet Explorer.

Internet Explorer


To turn Pop-up Blockers on or off, follow these steps:

  • Click Start, click Run, type inetcpl.cpl, and then click OK to open the Internet Properties dialog box. Alternatively, open Internet Explorer, and then click Internet Options on the Toolsmenu to open the Internet Properties dialog box.
  • Click the Privacy tab, and then do either of the following:
    • Click to select Block pop-ups to turn Pop-up Blocker on.
    • Click to clear Block pop-ups to turn Pop-up Blocker off.

Google Chrome


Manage pop-ups


Google Chrome prevents pop-ups from automatically appearing and cluttering your screen. Whenever the browser blocks pop-ups for a site, an icon appears on the top-right in the address bar. Click the icon to see the pop-ups that have been blocked or to manage pop-up settings for the site.

See pop-ups for a specific site

To see blocked pop-ups for a site, follow the steps listed below:
  • If pop-ups have been blocked, you'll see the icon in the address bar. Click the icon to see a list of the blocked pop-ups.
  • Click the link for the pop-up window that you'd like to see.
  • To always see pop-ups for the site, select "Always show pop-ups from [site]." The site will be added to the exceptions list, which you can manage in the Content Settings dialog.

To manually allow pop-ups from a site, follow the steps below:

  • Click the Chrome menu on the browser toolbar.
  • Select Settings.
  • Click Show advanced settings.
  • in the "Privacy" section, click the Content settings button.
  • In the "Pop-ups" section, click Manage exceptions.
Allow all pop-ups

You can allow all pop-ups by disabling the pop-up blocker. Follow these steps:
  • Click the Chrome menu on the browser toolbar.
  • Select Settings.
  • Click Show advanced settings.
  • in the "Privacy" section, click the Content settings button.
  • In the "Pop-ups" section, select "Allow all sites to show pop-ups." Customize permissions for specific websites by clicking Manage exceptions.


Firefox 


Pop-up blocker settings
To access the pop-up blocker settings:
  • At the top of the Firefox window, click on the Tools menu then click Options . If you don’t see Tools menu press Alt key on your key board then you will see menu bar across the top of the browser select Tools menu.
  • Select the Content panel.
In the content panel:
  • Block pop-up windows: Uncheck this to disable the pop-up blocker altogether.
  • Exceptions: List sites that you want to allow to display pop-ups. 
The dialog has the following choices:
  • Allow: Click this to add a website to the exceptions list.
  • Remove Site: Click this to remove a website from the exceptions list.
  • Remove All Sites: Click this to remove all of the websites in the exceptions list.
Note: Blocking pop-ups may not always work and may interfere with some websites

Safari


  • Open up your Safari Web browser.
  • Go to the Safari menu and choose 'Preferences' from the list of choices
  • Click on the Security heading.
  • Check the box marked 'Block pop-up windows' if you would like Safari to block all popups. Safari will then ask if you would really like to change the setting.
  • Click on the 'OK' button in order to change the setting.
  • Click on the box again, so it does not have a check mark, if you want Safari to allow popup windows.
  • Close the Preferences windows after you are done changing settings.
  • Shut down and restart Safari.

Thursday, 2 June 2016

We apologize for any inconvenience, but we've made the site read only while we're making some improvements.

When I browsed the site I got the following message: “We apologize for any inconvenience, but we’ve made the site read only while we’re making some improvements.”



Reason: 

The reason was backup of this specific site collection did not complete successfully. When you backup a Site, SharePoint places the site in read-only mode. But since my backup hanged the site never got out the read-only mode.

Solution:

  • Go to Central Administration.
  • Under Application Management go to "Configure quotas and locks".

  • Set Site lock information to "Not locked". 

 But it was grayed out and I couldn't change it directly.

Luckily since the April 2013 CU update for SharePoint 2013 we now have the SpsiteAdministration.ClearMaintenanceMode method. So we can clear the flag with the flowing two lines:

    $site = new-object Microsoft.SharePoint.Administration.SPSiteAdministration(‘http://intranet.demo.local’)
    $site.ClearMaintenanceMode()



and your site is out of maintenance mode again!



Friday, 22 April 2016

SharePoint 2013 – Workflow Manager 1.0 offline download & Installation

Problem:
I want to create SharePoint 2013 workflow in SharePoint Designer. But it is not showing SharePoint 2013 workflow option. So we need to first setup workflow manager.

There is no direct download to the Workflow manager and required components that need to Install and Configure Workflow Manager 1.o with SharePoint 2013.

If the server have Internet connection “Web Platform Installer” does the job for you. This is good for quick setup of development environment but what if we want to setup on a server that don’t have internet connection. Also for consistent builds (Dev/QA/production) we need to download and install the same software across all the environments.

Solution:

Below steps provide how to download the required Workflow Manager 1.0 components.

Here is the instructions from Microsoft link : http://technet.microsoft.com/en-us/library/jj906604

(Note: Please do not confuse with the below Microsoft link to download Workflow manager 1.0, again this is not full version).

Step 1: Log on to the machine where you have internet connection and down load the web platform installer “WebPlatformInstaller_amd64_en-US.msi” from here

Step 2: Extract the files from “WebPlatformInstaller_amd64_en-US.msi” to a folder. There are different ways to extract files from msi. below is the example using msiexec utilty.

Open Command prompt or powershell run as administrator and enter the below command:

msiexec /a <msi location with folder path> /qb TARETDIR = <folder location where the files needs to be extracted>

Ex:

msiexec /a C:\SharePoint\SP2013\Tools\WebPlatformInstaller_amd64_en-US.msi /qb TARGETDIR=C:\
ePoint\SP2013\Tools\wpi

It will extract the folder structure as below.


Required “WebpiCmd.exe” available under <above target location>/Microsoft/Web Platform Installer

Step 3: Download Workflow Manager components using WebpiCmd.exe

In the command prompt or powershell

webpicmd.exe /offline /Products:WorkflowManager /Path:<folder directory to download>


Lets Install and configure workflow manager with SharePoint Server 2013…

Step1: The Workflow Components are downloaded as below folder structure..



Step 2: Run the below command to invoke the Workflow Manager Configuration Manager screen..

WebpiCmd.exe /Install /Products:WorkflowManager
/XML:<directory of workflow manager downloads>
/feeds/latest/webproductlist.xml
Eg: below..



Step 3: Workflow Manager Configuration Wizard screen starts...



Step 4: Click on Configure Workflow Manager with Default settings (Recommended). New Farm Configuration wizard opens and enter the required fields.  (Here I am talking about minimum required fields for configuration, there are advanced option parameters for setup a production farm)

SQL Server Instance: i.e The Database server for the Workflow Manager databases

Configure Service account: a dedicated domain service account for work flow manager

Certificate Generation Key: similar to Passphrase in SharePoint a password for securing the workflow manager farm. this is required when workflow manager farm extended..



Step 5: On clicking Right arrow bottom of the screen, configuration starts



Step 6: Upon successful installation all the check marks are passed with green



Step 7: Workflow manager is setups a IIS web site on the box hosting on port 12290 (for ssl) and 12291 for http (non ssl). you can add host url for the ports that are of interest in configuration such as workflowmanager (This way we can avoid using the server FQDN name while configure with SharePoint site collection)
you can verify the workflow manager Installation by accessing http://localhost:12291 or http://<host url>:12291 (if host url configured). XML file with configuration detail opens..
Step 8: Now run the below SharePoint PowerShell command to configure the workflow manager with a SharePoint 2013 site collection
Register-SPWorkflowService –SPSite “http://myserver/mysitecollection&#8221;
–WorkflowHostUri “http://workflow.example.com:12291&#8221;
–AllowOAuthHttp
Step 9: Verify the Workflow Manager configured successfully with the site collection by using SharePoint Designer 2013





Register-SPWorkflowService Failed to query the OAuth S2s metadata error

Scenario: 

You have followed all the specified TechNet requirements/permissions in setting up SharePoint 2013 and Workflow Manager 1.o farm but when Registering Workflow manager with SharePoint site collection you might have got the below error:

Register-SPWorkflowService : Failed to query the OAuth S2S metadata endpoint at URI ‘http://xxxx/_layouts/15/metadata/json/1&#8217;. Error details: ‘An error occurred while sending the request.’. HTTP headers received from the server – ActivityId: 5b035802-7a59-4235-acb5-943a0e21e942. NodeId:
xxxx. Scope: /SharePoint. Client ActivityId : 66bd6434-9778-4a6f-b275-63a399d73c8c.

Solution:

Basically it is trying to connect to the SharePoint url end point (http://xxxx/_layouts/15/metadata/json/1 . In my case the SharePoint url (which has host header) was not accessible from Workflow Manager server (as I have not dns published the url). I added the SharePoint url to the Workflow manager server host file and can access the SharePoint url.

Now the Register-SPWorkflowservice command runs without issue.

Key here is that make sure that both SharePoint and workflowhost urls are accessible from the SharePoint / Workflow Manager server.

Hope this helps.

Friday, 8 April 2016

Scheduling Search Crawl in SharePoint

If you want to configure Full/Incremental/Continuous search crawl, follow below steps:

  • On the Configure Search Settings page, in the Crawl Settings section, click Content sources and crawl schedules.
  • On the Manage Content Sources page, right click the content source for which you want to schedule an incremental crawl and then click Edit.
  • On the Edit Content Source page, in the Crawl Schedules section, do the following:

Incremental/Full crawl setup:

  • If an Incremental/Full crawl has never been created for this content source, click the Create schedule link below the Incremental/Full Crawl list.    -or-
  • If you are changing the Incremental/Full-crawl schedule, click the Edit schedule link below the Incremental Crawl list.
  • In the Manage Schedules dialog box, in the Type section, select Daily, Weekly, or Monthly.
  • In the Settings section, do the following:


  1. In the Run every box, type the number of days between crawls. For example, to schedule an incremental crawl to start every other day, type 2.
  2. In the Starting time list, select the time of the day from which to start the scheduled crawl.
  3. If you want to crawl more frequently than once a day, select the Repeat within the day box and type the number of minutes to wait between crawls in the Every box and type the total number of minutes in which to repeat the crawl within the same day in the For box. For example, if you select Repeat within the day and type 60 in the Every box and 720 in the For box, an incremental crawl of the content source you are configuring starts every 60 minutes up to 720 minutes (12 hours) after the first scheduled incremental crawl for this content source ran.
  4. Click OK.


  • Click OK in  Content Source page.

Continuous crawl setup:

  • Select the continuous crawl radio button in Crawl Schedule Section.
  • Click OK in  Content Source page.

Unlike an incremental crawl, which starts at a particular time and repeats regularly at specified times after that, a continuous crawl automatically starts at predefined time intervals. The default interval for continuous crawls is every 15 minutes.

To Change the Continuous crawl time do the following steps:

Prerequisite:

  • Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

Steps:


  • Start a SharePoint 2013 Management Shell.
  • At the Windows PowerShell command prompt, type the following commands:

        $ssa = Get-SPEnterpriseSearchServiceApplication

        $ssa.SetProperty("ContinuousCrawlInterval",n)

        Where: n is the regular interval in minutes at which you want to continuous crawls to start. The default interval is every 15 minutes. The shortest interval that you can set is 1 minute.

Note:

If you reduce the interval, you increase the load on SharePoint and the crawler. Make sure that you plan and scale out for this increased consumption of resources accordingly.

Source:

    https://technet.microsoft.com/en-in/library/cc263373%28v=office.12%29.aspx
    https://technet.microsoft.com/en-us/library/jj219802.aspx

Friday, 5 February 2016

SharePoint Naming limitation in site names, folder names, and file names

This article lists the characters that you cannot use in the following names in Microsoft SharePoint:

  • Site names
  • Folder names
  • Server names
  • File names

Site names, sub-site names, or site group names

You cannot use the following characters anywhere in a site name, in a subsite name, or in a site or Active Directory group name:
  • Tilde (~)
  • Number sign (#)
  • Percent (%)
  • Ampersand (&)
  • Asterisk (*)
  • Braces ({ })
  • Backslash (\)
  • Colon (:)
  • Angle brackets (< >)
  • Question mark (?)
  • Slash (/)
  • Plus sign (+)
  • Pipe (|)
  • Quotation mark (")
  • You cannot start a site name, a subsite name, or a site group name with an underscore (_) character or with the period (.) character.
  • When you create a site name, a subsite name, or a site group name, you cannot use strings that were already used to name managed paths.
  • You cannot use the period character consecutively in the middle of a site name, a subsite name, or a site group name.
  • You cannot use the period character at the end of a site name, a subsite name, or a site group name.


Folder names

You cannot use the following characters anywhere in a folder name or a server name:
  • Tilde
  • Number sign
  • Percent
  • Ampersand
  • Asterisk
  • Braces
  • Backslash
  • Colon
  • Angle brackets
  • Question mark
  • Slash
  • Pipe
  • Quotation mark
  • You cannot use the period character consecutively in the middle of a folder name.
  • You cannot use the period character at the end of a folder name.
  • You cannot start a folder name with a period character.
  • If you use an underscore character (_) at the beginning of a folder name, the folder will be a hidden folder.
  • Additionally, a folder that contains the string "_vti_" is reserved by SharePoint, and isn’t supported.
File names

You cannot use the following characters anywhere in a file name:
  • Tilde
  • Number sign
  • Percent
  • Ampersand
  • Asterisk
  • Braces
  • Backslash
  • Colon
  • Angle brackets
  • Question mark
  • Slash
  • Pipe
  • Quotation mark
  • You cannot use the period character consecutively in the middle of a file name.
  • You cannot use the period character at the end of a file name.
  • You cannot start a file name by using the period character.
  • If you use an underscore character (_) at the beginning of a file name, the file will be a hidden file.
  • File names and folder names may not end with any of the following strings: 
    • .files
    • _files
    • -Dateien
    • _fichiers
    • _bestanden
    • _file
    • _archivos
    • -filer
    • _tiedostot
    • _pliki
    • _soubory
    • _elemei
    • _ficheiros
    • _arquivos
    • _dosyalar
    • _datoteke
    • _fitxers
    • _failid
    • _fails
    • _bylos
    • _fajlovi
    • _fitxategiak
  • In addition, file names and folder names cannot start with the “_vti_” string, such as the followings:
    • _vti_cnf
    • _vti_pvt
    • _vti_bin
    • _vti_txt
MSDN Link: https://support.microsoft.com/en-us/kb/905231

Thursday, 4 February 2016

How to add separator to string at every N characters?

I was having a strange requirements last days and one of them is this one:

we have a string and we want to add a separator after 8 digit.

Here is the post which help me to achieve the my solution:
http://stackoverflow.com/questions/9932096/add-separator-to-string-at-every-n-characters

Solution:

here is the solution that worked for me:

string x = "111111110000000011111111000000001111111100000000";
output should be :
"11111111,00000000,11111111,00000000,11111111,00000000,"

C# : Regex.Replace(myString, ".{8}", "$0,");

Javascript:

"111111110000000011111111000000001111111100000000".replace(/(.{8})/g,"$1,")


Error Occurred in Deployment step 'Recycle IIS Application Pool'

Currently we have moved our development environment and one common error I faced after moving them was :
Error occurred in deployment step 'Recycle IIS Application Pool':
<nativehr>0x80070005</nativehr><nativestack></nativestack>Access denied

Solution:

Original Post: http://stackoverflow.com/questions/21278281/error-occurred-in-deployment-step-recycle-iis-application-pool

Here are the steps that worked for me:

  1. Go to Central Administration site
  2. Navigate to the Manage Web Applications page
  3. Click on the web application that hosts the site you are trying to deploy to
  4. Click the User Policy ribbon item.
  5. Add your windows account to the list of users with the Full Control permission.

Friday, 8 January 2016

Error: Value does not fall within expected range SharePoint

While accessing SharePoint Document Library files I face a strange error as the code I was using was used before and was working fine earlier. Here was the error message:

Error: Value does not fall within expected range

Code Sample:

SPFileCollection files = currentlist.RootFolder.SubFolders[curfileitem.Url.Substring(0, curfileitem.Url.LastIndexOf('/'))].Files;

I found that if I have hierarchy of folder then the above code will throw an error.                        

Solution:

Through google I found out a new method to get files collection. Here is the code sample:

SPFolder folder = properties.Web.GetFolder(curfileitem.Url.Substring(0, curfileitem.Url.LastIndexOf('/')));

SPFileCollection files = folder.Files;

Make sure you provide full path of your folder. i.e. your web path / doc library title / folder path.