Wednesday, October 23, 2013

How to Log Errors in SharePoint Hosted Apps?

It is most common thing to log error message if some exception occurs within the code, so that user can find out what causing the error. It is straight forward if you using Server side object model. Since Hosted apps only use JavaScript object model and its bit new to many of us, not sure which namespace/class to use.

 

We use SP.Utilities.Utility.logCustomAppError method to log the app errors. Following is the sample code

 

 

function onFail(sender, args) {

    logAppError(args.get_message() + '\n' + args.get_stackTrace());
}

function logAppError(message) {
    SP.Utilities.Utility.logCustomAppError(context, message);
    this.context.executeQueryAsync();
}

Wednesday, October 16, 2013

SharePoint 2013 App Model – How to View list With in APP

If you working on SharePoint 2013 APP, at some point you defiantly want to see list items contained within the app. Unfortunately there is no navigation to traverse to list.

 

To view specific list in “APP Web”, you directly type the url which specified in the following format in browser

http://<APP WEB URL>/<APP NAME>/Lists/<List Name>/AllItems.aspx

Ex: http://app-0eb6021fad963e.apps.com/sites/SP2K13/WhiteCaseEDARAPP/Lists/Calendar/AllItems.aspx

 

If in case you want to see the List settings,

  • Click “Modify View” under List tab

image

  • Click on “Settings” link as shown below

image

Friday, August 30, 2013

SharePoint 2007 – Custom Alert Template Issue

Recently one of our Business user requested to use “Custom Alerts on old SharePoint” even though we are in the process of upgrading to SharePoint 2013.

 

Anyway I found a nice article to implement “Custom Alert Templates” here. This is what I did, in simple steps.

  • Created a copy of “AlertTemplates.xml” found in 12 hive\Templates\XML
  • Created a new “AlertTemplate” section with in the XML and gave the unique name (simply copy the GeneraicList and renamed the Name)
  • Made couple of changes to Styles and layout (adding new tables to show Company logo)
  • Ran the STSADM command to update the template
  • Create a  small tool in VS to update the template name to specific list
  • Reset the IIS
  • Reset the SharePoint Timer Service

 

Even though I followed same as mentioned in the article, still alert emails are defaulting to the old template no matter what i did (Even I made exact changes to generic list section to see at least its falling into that)

 

After spending couple of days, I removed existing alerts on the list and created new one. Now i see the emails with update template.

I found out that, if we already have alerts setup on the list before updates, even you change the list to use different template (through code), SharePoint still sends alert emails using the template that was assigned to the list at the time of Alert setup.

 

Lesson learned !!!

Tuesday, July 9, 2013

SharePoint 2013 - “We’re having a problem opening this location in File Explorer, Add this web site to your Trusted sites list and try again”

I got the following error, when I try to open the library within file explorer, I received following error message

 

“We’re having a problem opening this location in File Explorer, Add this web site to your Trusted sites list and try again”

image

As it says, i tried to add the current site to Trusted List, but still having the issue to open in file explorer. After goggling a bit, I found that I have to enable the “WebClient” service.

 

Steps

1. Go to Run, type “Services.msc” and press Enter.

2. Select “WebClient” service and start the service, if you already have.

For me it’s not showing, so I have to Install “Desktop Experience” feature. To do that

1. Go to Run, type “Server Manager” and press Enter.

2. Select Features and then select Add Features

image

image

3. Select “Desktop Experience” checkbox and select “Add Required Features” on following popup screen

image

4. Click “Next”

5. Click “Install”

6. Once you restart the computer, start the “WebClient” service.

image