Search This Blog

Showing posts with label Workaround. Show all posts
Showing posts with label Workaround. Show all posts

Sunday, March 26, 2017

Disable mobile view redirection in SharePoint 2010

When SharePoint 2010 site is accessed in mobile devices, it shows stripped down version of the site with limited features for mobile devices. SharePoint redirects to a special page responsible for rendering the mobile view. This may be helpful if you want to keep minimalist approach for mobile devices.

However; most of the time you  want to disable this behavior as the design itself may be responsive thus not requiring the mobile view redirection.

There are 3 options available to do this:

Disable MobilityRedirect Feature in SharePoint using power shell. 

Disable-SPFeature -Identity MobilityRedirect -Url http://yoursite

It appeared to be the best option, without requiring you to change the lines in Web.Config. But it did not work for me.

Change compat.browser

Navigate to "C:\inetpub\wwwroot\wss\VirtualDirectories\[port-of-your-site]\App_Browsers\compat.browser" and change "isMobileDevice" property to false for each user agent present.

This is the least preferred option for me as it requires to change values at multiple places and this may get overwritten with new patches.

Change web.config file of the web application

Open the web.config file for the web application and navigate to the "". 
Add the following lines of code:

<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<filter>isMobileDevice=false</filter>
</browserCaps>

I feel this is the most fail safe way. This does not have risk of values being overwritten due to new patches to the server.

More information on this can also be found at perficient blog

Saturday, March 19, 2011

Updating List Item from Workflow and avoid repeated firing of workflow

I have a list having a custom workflow attached to it. Workflow is executed whenever any updates are done to the item. Apart from performing various other task, the workflow also need to update a field of that item.

So what is the problem?

There is no issue updating any item from the workflow. You can use workflowProperties.Item["FieldName"] = "Value" to update any field. The side effect is updating the item triggers the workflow again as it is configured to execute when item is modified. This causes the workflow to run in indefinite loop.
So what is the solution?

Create a new class within the workflow and inherit it with SPItemEventReceiver. Create two new functions called DisableWorkflow() and EnableWorkflow().

Inside DisableWorkflow() add a line –
this.DisableEventFiring

Inside EnableWorkflow() add a line –
this.EnableEventFiring

That’s it, just create a object of this class, call DisableWorkflow() just before workflowProperties.Item.Update() .Then call EnableWorkflow() after updating the item.

Sunday, July 26, 2009

Display Lists in another Site.

I was searching for workaround to display listview of lists in another Site and have come across the fantastic solution for this on "PathToSharePoint" blog.

Here is the link for all those guys searching for it.

http://pathtosharepoint.wordpress.com/2009/01/22/a-simple-method-to-display-a-list-in-another-site/

All the best.