Saturday, April 11, 2015

New SharePoint CSOM update for Office 365

Wow. This is such a great build. Loving the new additions added in the new SharePoint CSOM for Office 365. Since a year, was submitting the feedback and waiting for some features has to be included in the CSOM API and here they are. You can do even more with the new API methods and classed added. The package will be available via Nuget.

Version: 16.1.3912.1204.

The major feature I really impressed are:
  • Manage regional settings of a site
  • Manage language settings of a site
  • Manage auditing settings of a site
  • Support for upcoming enhanced migration APIs
  • Secondary contact in site collection level
  • Sharing settings
  • Tenant
The auditing settings API is a major help for me along with the Sharing settings. There are over 50 methods added across and the major ones which might help you are:
  • Accessing document set properties, documents
  • Added classes related to Search PushTenant
  • Additional properties for Publishing classes
  • Accessing AppCatalog
  • Audit information
  • File, Folder methods and properties
  • Many Web and Site properties and methods. 
If you are feeling like you are unable to implement just because of product limitation then it's for you. Go and have a look at the new update and start building the examples. 

Get more details about complete CSOM methods and properties here.

Wednesday, April 8, 2015

Show user profile pictures in SharePoint Hosted Apps

This is the issue which killed more than a week of my time. Many users are facing it too and I see the same question in almost all the forums. Proud to tell that the solution which I have found is the most usable one for SharePoint Hosted App world.

In SharePoint Hosted Apps the cross-domain calls are limited. The issue I am facing in SharePoint Online Hosted Apps was:

I have created a SharePoint hosted app which has the code to show the user profile picture. I have tried below options for it:

  1. Queried the REST API user profile and then 
    1. used the "PictureUrl" from user profile metadata. But, no luck with this. Then,
    2. used the "UserProfileProperties -> PictureURL attribute in the results. Still, there is no luck. 
  2. Used the Outlook Office 365 profile picture link: 
    1. But, the url is an external site link the picture failed to load.
  3.  Used the UserPhoto.aspx page in the _layouts folder: /_layouts/15/userphoto.aspx?size=L&accountname=encodeduseraccountname.
    1. I have tried with both hosted web url and app web url. But, no luck. 
    2. But, if I create a App Part and in the app part the same image path shows perfectly. So, the issue is only in the App landing page. 
Published the issue in all social networking sites, forums for help, but no luck. Many people come up with different ideas, but nothing worked. 

After spending the good amount of time in analyzing the UserPhoto.aspx, and how it works, I was able to find a way to download the image. 

UserPhoto.aspx accepts many parameters. We always use the AccountName querystring to download the image of the user. But, it also accepts other paramters like "url". 

So, the solution I used here is: 

Note: You must query the User profile REST API for the user to get the user profile picture url and then encode that picture url and then replace the string {encodeduserprofilepictureurl} with that.

This one given me the output I wanted. Now, the pictures are showing everywhere, inside the app and also in app part...