Wednesday, November 11, 2015

VirtualBox shows only 32 bit guest versions ― and how I fixed it

I recently purchased Lenovo Yoga 500 with 64-bit Windows 10. I installed Oracle VirtualBox on it but was surprised to find that I could only install 32-bit versions of OS on it. I found this article which suggested toggling Intel (R) Virtualization Technology and Intel (R) VT-d Feature settings in BIOS. But in my laptop I couldn't find this setting. Rather you will find a setting under Configuration tab called Intel Virtual Technology and enable it.



Reboot your system and now try to install OS in VirtualBox and it should now show both 32-bit and 64-bit versions of OS.

Thursday, July 2, 2015

How to sort SharePoint object of SPWeb in SPWebCollection based on Title?

A questioner posed an interesting question on SharePoint StackExchange – how to get all the web sites (SPWeb) in SharePoint and sort them alphabetically.

SPSite.AllWebs returns a collection of all web sites that are contained within the site collection. But they seem to be in random order and are not sorted alphabetically based on their Title. Sorting these web sites based on their title is actually pretty easy.

SPSite.AllWebs returns object of SPWebCollection which inherits from IEnumerable<T> interface. This interface has a function called OrderBy using which we can order the SPWeb based on its Title property.

SPWebCollection webColl = site.AllWebs;
// Sort the SPWeb alphabetically based on Title
IEnumerable sortWebColl = webColl.OrderBy(w => w.Title); 
foreach (SPWeb web in sortWebColl) {
    // Code
}

You also need to make sure that you use the following namespaces otherwise it will throw error.

using System.Linq;
using System.Collections;
using System.Collections.Generic;

You can extend the above code snippet to sort based on Description and other properties of SPWeb also.

Wednesday, May 20, 2015

Get appWebUrl and hostUrl in SharePoint Online / Office 365

When you are developing in SharePoint Online / Office 365 you will have to fetch appWebUrl and hostUrl if you want to perform any operation on your lists and libraries. I could find two ways of getting these values.

1. Reading values of SPAppWebUrl and SPHostUrl from query string


When you run your project it opens up the page Default.aspx. The URL of this page looks something like this.


Notice the query string parameters of SPAppWebUrl and SPHostUrl. You can fetch these values via a helper function.

Friday, April 24, 2015

Permission, Permission Level and Permission Policy in SharePoint

Permission, Permission Level and Permission Policy are three very different functionalities yet closely related in SharePoint. This article presents my understanding of what they are and how they work in SharePoint. It has been written with SharePoint 2010 in reference.

Permission


Permission means an action allowing someone to do a particular thing. In SharePoint it means the same. So you have permissions like Add Items, Edit Items, Delete Items and 30 more permissions. Yes, there are in all 33 permissions in SharePoint.

Permissions are divided into three categories.

  • Site Permissions (18) – apply generally across a SharePoint site
  • List Permissions (12) – apply to content in lists and libraries
  • Personal Permissions (3) – apply to content that belongs to a single user

Permissions also depend on other permissions. For e.g. you must be able to open an item to view it. In this way, View Items permission depends on Open permission. Below is the complete list of all the permissions and dependent permissions.

Thursday, April 9, 2015

Disable uppercase menu in Visual Studio

When I started learning SharePoint I came across Visual Studio and its hideous upper case menu.


I don't know what was the reasoning behind this, but in Visual Studio Community 2013 version you turn this off to show more conventional title case menu.

For this go to "Tools > Options". Under "Environment > General" enable the option of "Turn off upper case in menu bar".


And you will get the menu in title case.


Monday, April 6, 2015

Split string in JavaScript using regular expression

JavaScript has split() method which returns array of the substrings based on the separator character used. But you can also split a string using regular expression.

Say you have a credit card number which you want to split in array of four substrings with each substring consisting of 4 digits. For that you would use the match method of string.

var strValue = "1111222233334444";
var splitValues = strValue.match(/(\d{4})(\d{4})(\d{4})(\d{4})/);

// Start looping array from 1st index position as 0
// index position contains the entire parent string
for (var i=1 ; i<splitValues.length ; i++) {
 // Loop through the elements
}

Here, you use the match method and pass it the regular expression of (\d{4})(\d{4})(\d{4})(\d{4}) to split it into four equal substrings of four digits each. One thing to remember here is that the string returned here contains the parent string at the 0 index position and then the split substrings start at 1st position.

There is limitation here though — you need to know the number of characters in the string before hand, which might not be the case always.

Thursday, February 5, 2015

Significance of BaseViewID="0" in schema.xml for SharePoint List Definition

Whenever you create a SharePoint List Definition in Visual Studio the schema.xml file contains two entries for View.

<View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">

<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" 
      DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" 
      DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" 
      SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" 
      Url="AllItems.aspx">

Note that one of the views has BaseViewID="0" while other one has BaseViewID="1". The view with BaseViewID set to 1 is the default view with Url set to AllItems.aspx. But the view with BaseViewID set to 0 has no Url attribute set. Any modification for BaseViewID="1" gets reflected on the default view but I couldn’t figure out where the BaseViewID="0" view was being used. Even MSDN documentation is not very clear about it. A bit puzzled about this I posted this question on SharePoint StackExchange and was pointed to this answer which explains the reason for this additional view.

Wednesday, February 4, 2015

Prevent adding duplicates records from predefined data in ListInstance while reactivating its feature

In SharePoint if we have predefined data in ListInstance then deactivating and then reactivating its feature causes the predefined data to created again resulting in duplicates. Say, for e.g. our ListInstance looks something like this.

<ListInstance ...>
  <Data>
    <Rows>
      <Row>
        <Field Name="Title">Record 1</Field>
      </Row>
      <Row>
        <Field Name="Title">Record 2</Field>
      </Row>
    </Rows>
  </Data>
</ListInstance>

If we deploy this to a SharePoint site and if we deactivate and reactivate its feature then we will have “Record 1” and “Record 2” appear twice. Deactivating and reactivating it again would only create more duplicates.

Monday, January 19, 2015

Curse you Adobe!

Its 2015 and Adobe Reader still asks for system restart when it updates itself. It greets you with a dreadful message after every update:

You must restart your system before using Adobe Reader. Click Restart Now to restart automatically.

This wasn't the first time that I got this message and I am not the only one to question this (by the way this question was asked way back in 2011).

So when I got this popup again some days back, I accidentally clicked on "Restart Now". And my PC restarted itself. With me working on 3 different Word documents and 1 Excel worksheet. With a Ubuntu running in my VM. And it didn't even ask me if I wanted to close my open programs. It simply restarted.

I initially suspected this to be a problem with Windows; that it didn't ask me to close my open programs. So when today I got a couple of updates for my Windows, it again asked me for a restart. This time I opened up a Word document tried to restart to finish installing updates. It showed me message that I have some programs running. I closed my Word document and fired up my VM running Ubuntu. Again the same message.

So it seems to me that Adobe Reader's restart uses some kind of forced restart which does not care about the programs currently running on your PC. And that's why I say —

Curse you Adobe!

Sunday, January 18, 2015

Open command prompt from Windows Explorer in folder path and vice versa

Many a times you have Windows Explorer opened to a folder location and you need Command Prompt to be opened in that same location. Rather than opening Command Prompt and then navigating to the said directory there is a better way.

Hold down Shift key and right-click. Click on “Open command windows here”. This feature seems to have been present since Windows Vista.



Conversely, if you are in your Command Prompt in a specific folder and you want to open that folder in Windows Explorer then simply type in the following command:

Sunday, August 24, 2014

Installing Ubuntu on VirtualBox

I have a Windows 8 machine on which I will be installing Ubuntu 14.04 inside Oracle VM VirtualBox. First download VirtualBox and install it. For this example I am using 4.3.12. Download the image file for Ubuntu.

Once you have installed VirtualBox open it and click on "New" on the toolbar to begin the process of creating a new virtual machine.


Give a name to your virtual machine and select which OS you would be installing in it and click on "Next".


Sunday, August 10, 2014

Remove passwords from PDF files

A very simple trick to remove passwords from your password protected PDF files so that you can forward them.

Open your password protected PDF file in Google Chrome. Now hit Ctrl + P and save password protected PDF file as, well, again a PDF file. This would save a copy without the password.

Tuesday, August 5, 2014

Enable "Developer options" on your HTC One X

Recently I noticed that the Developer options on my HTC One X was gone. I remembered before updating it to 4.2.2 it had the Developer options. Then I remembered that from Android 4.2 and higher the Developer options are hidden by default.

To get back Developer options go to "Settings > About > Software information > More". Once there tap on "Build number" seven times to enable it.

Friday, August 1, 2014

Remove Skype from taskbar in Windows when you close it

Skype has an annoying bug feature; when you close it, it does not disappear from the taskbar unlike other programs. To make Skype behave like other programs, in menu go to "Tools > Options". Under "Advanced > Advanced settings" uncheck "Keep Skype in taskbar while I'm signed in".


So now when you close Skype it disappears from taskbar but it is still running and you can see it in notification area of taskbar.

Tuesday, July 22, 2014

Using ‘html’ option in SP.UI.ModalDialog.showModalDialog

I was trying to use SP.UI.ModalDialog.showModalDialog with html option using the below code:


But I was running into this weird error:

Wednesday, July 16, 2014

Sharing folders between Windows (host) and Ubuntu (guest) in VirtualBox

I have Windows 8 installed with Ubuntu 12.04 in Oracle VM VirtualBox and quite a few times I want to share files between them. For that, first you need to install VirtualBox Guest Additions for Linux. Guest additions consist of device drivers and system applications that optimize the guest operating system for better performance and usability.

To install Guest Additions go to Ubuntu Launcher and you would see VBOXADDITIONS_X.X.X_XXXX mounted.


Tuesday, June 24, 2014

Create Facebook cover photo from your HTC phone

HTC provides a nifty option to crop the photos in dimension specified for Facebook cover photos i.e. 851×315.

  1. Open the picture that needs to be cropped from your Gallery.
  2. Tap on “Edit” and then tap on “Transform”.
  3. Select “Crop” option.
  4. Now tap on the overflow icon (three vertical dots) and select “Facebook cover”.
  5. The cropping tool will now resize in proportionate to the dimensions specified for Facebook cover photo.
This option is present on my HTC One X running on Android 4.2.2 with Sense 5 and I am guessing here that it should be present in other HTC phones with Sense 5. If it doesn't then let me know in comments.

Tuesday, June 17, 2014

Find and delete large attachments from your Calendar in Outlook 2010

Over time your Outlook gets filled with quite a few Calendar entries and some of those entries have attachments in them which were take up unnecessary space. To find those Calendar entries in Outlook 2010 follow these steps:

1. Open your Calendar in Outlook 2010.

2. Go to “View” tab. Go to “Change View” and select “List”. You will get a list of all your Calendar appointments.


3. Click on “Add columns” in “View” tab.


4. From dialog select “All Appointment fields” and add “Size” from available columns.


5. You can now see the size column in your list which you can sort to identify the entries which have large attachments in them.

Friday, January 31, 2014

Authorization problem for Facebook in HTC One X

I recently started receiving error of "Authorization problem" on my HTC One X with my Facebook app. It seemed that HTC Sense was not able to access my Facebook account and this error message continually popped up in my notification.

Sunday, January 19, 2014

Zoom in and out with single hand on Google Chrome for Android

Some time back I ran into this article which detailed about a nifty feature which enables you to zoom in and out of Google Maps by just one finger. To perform a one-hand zoom simply double tap and, after the second tap, leave your finger pressed. You can then move your finger up and down to zoom in an out.


And after the recent update to Google Chrome on Android (version 32) I found that this feature has been also been added there. So now you can zoom in and out using just one finger.