Monday, August 26, 2013

InfoPath 2010 Programmatically set web service parameters for Data Connection (WebServiceConnection)

When developing InfoPath forms, have you ever needed to dynamically set the parameters of a web service during run time?
I have.

Using the SharePoint Taxonomy web service as an example., here's what I did:
First, I create a Data Connection which points to the TaxonomyClientService web service found in _vtu_bin/TaxonomyClientService.asmx. I am calling the web method GetTermSets.

For this particular web service, there are several parameters that need to be passed in.
You can refer to the other article for more details InfoPath 2010: Populating a dropdown with SharePoint Metadata Termstore

I opt not to automatically retrieve data when form is opened.

For each Data Connection that was created, there will be a corresponding secondary Data Source. I am going to make use of the XML for my dynamic updates.


Tuesday, August 20, 2013

Phuket Island Tour - Maya Bay, Phi Phi Island and Khai Island

Weather: cloudy with occasional thunderstorms
When: mid-July
Places: Maya Bay - Phi Phi Ley, Viking Island, Monkey Beach, Phi Phi Island, Khai Island

After the shuttle bus picked us up from our hotel, we arrived at the pier where the tour guide, a very cute and funny 'lady' named Mary, gave us an entertaining narrative of what to expect during today's tour.
There were a total of 3 speedboats for our group today. (This is merely the off peak season and the tour operator is just one among the many hundreds available in Phuket. So you could imagine the crowd during the peak season...)

Picture of the speedboats.

As we set out from the pier, there was a light drizzle (still ok), but the waves were... scary. I was told that some waves were as high as 3 meters. After enduring one hour of a bumpy ride, we reached the first destination - Maya Bay. Well I certainly wasn't expecting my first sight of the beach to be .. this. Hehe

I was amazed by how well maintained the beach was, given the sheer size of the crowd. Thousands of  visitors flock to the spot every day to catch a glimpse of the famous filming location which is Maya Bay. Some people might know it by the name of James Bond Island.






The turquoise waters and pristine white beach is gorgeous even on a rainy day. It wasn't easy, but I managed to capture some photos with unobstructed views.

Sunday, August 18, 2013

Phuket Island Hopping Trip - How to select your preferred tour

Visiting Phuket in the middle of the monsoon season (mid-year) is always a risk - it could be sunny in the morning, and flash thunderstorms in the afternoon! This made planning extremely difficult.

But since I am already here, why not take a gamble, I thought to myself. To hell with rain or shine.

Island hopping trips in Phuket are divided into 3 main itineraries:
- Sightseeing: James Bond Island, Phang Nga Bay, Canoeing
- A bit of snorkeling: Phi Phi Islands, Maya Bay, Khai Island
- A LOT of snorkeling: Coral Island and Racha Island, OR Similan Island
I went for the Phi Phi Island option. I would have liked to see Phang Nga bay as well but there simply wasn't enough time.
You could either opt for speedboat (faster, more stops) or ferry (leisure)

Getting a tour from Patong beach area is really simple if you are willing to do the price and comparison.


There are so many options available and most of the itineraries are in fact the same. Based on my personal experience, here's what to do when selecting a tour:
- Price! Cheaper during monsoon seasons, you should be able to get Phi Phi around 1000-1100 baht after discount. For Phang Nga, it's probably around 1000 baht. I did not check for others. This is per 2013.
- Do not be greedy and go for the itineraries with the most stops during the monsoon season. It will be hugely dependent on weather conditions.
- Try to book a couple of days in advance and don't rush to book the first (cheap) package you see. There's always a better deal at the next tour operating just a few steps ahead.
- Some operators will offer more discounts if you book in a group of 4 or more.


Just walk around and ask. There are at least dozens, if not hundreds of options.

Thursday, August 15, 2013

Intermittent error: The type initializer for '' threw an exception

I had built a web application to consume SharePoint 2010 Word Automation Services to perform PDF rendition. From time to time, I noticed this exception would be thrown:

System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.TypeInitializationException: The type initializer for '' threw an exception. ---> .ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
 ---> System.ArgumentException: Invalid token for impersonation - it cannot be duplicated.
   at System.Security.Principal.WindowsIdentity.CreateFromToken(IntPtr userToken)
   at System.Security.Principal.WindowsIdentity..ctor(SerializationInfo info)
   at System.AppDomain.get_Id()

After Googling around I arrived at the conclusion that somehow, the user account I am impersonating have its token expire after prolonged use, and was refused by the Word Automation Services. I'm too lazy to list references and explanations so let's dive into a simple workaround straightaway!

InfoPath 2010: Populating a dropdown with SharePoint Metadata Termstore

In one of my projects, I had to build an InfoPath 2010 form needs to populate a couple of dropdown lists with values from the SharePoint metadata term store.

In a nutshell, this is how I managed to get it working:
Using PowerShell, I extracted the IDs of the Metadata service name, and the IDs of the term set name.

$col = Get-SPSite http://sharepoint
#Get TermStore ID
$taxonomySession = Get-SPTaxonomySession -site $col
$termStore = $taxonomySession.TermStores["Managed Metadata Service"]
$termStore.Id

#Get TermSet ID
$termStoreGroup = $termStore.Groups["Departments"]
$termSet.Id

SharePoint 2010 and Javascript: Coding a Popup Modal Dialog

Ever wondered how to embed a popup modal dialog in SharePoint? Here's the javascript needed to do the trick:
// Here I am passing the current list ID and list item ID as a querystring parameter to an aspx page to perform some functions

function CustomOpenDialog(listid, listitemid) {
    var options = SP.UI.$create_DialogOptions();
    var url = SP.ClientContext.get_current().get_url();
    options.url = url + '/SitePages/MyTestPage.aspx?listid=' + listid + "&listitemid=" + listitemid;
    options.width = 500;
    options.height = 400;
    options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
    SP.UI.ModalDialog.showModalDialog(options);
}

var messageId;


function CloseCallback(result, target) {
    if (result === SP.UI.DialogResult.OK) {
        if (target != 'bye') {
            //Get id
            messageId = SP.UI.Notify.addNotification('<img src="_layouts/images/loading.gif">Loading... <b>' + target + '</b>...', true, 'Dialog Response', null);
            //do someother work here.
        }
        else //target=='bye'
        {
            SP.UI.Notify.removeNotification(messageId); //simple way to remove it.
            return;
        }
    }
    if (result === SP.UI.DialogResult.cancel) {
        SP.UI.Notify.addNotification('Operation was cancelled...', false, '', null);
    }
}

This is by no means a complete solution. Most of the time, you will find yourself working with either SharePoint Designer or Visual Studio to provide a more comprehensive solution.

Happy Sharing the Point!
Related Posts Plugin for WordPress, Blogger...