Posts

Showing posts from October, 2013

SharePoint 2013 - Display Notification on Parent Page after App Part completes its task

For a typical web part operation, you usually display some kind of message/notification when you completed a task.  So that user know the status.  The problem with the App part is that it's within an iFrame on the page.  You can't just call SP.UI.Notify.addNotification(""). The OOTB App Part support resizing of iFrame with postMessage technique only.  So, what to do ... Below is a technique that allows you to display the SharePoint popup notification on the top right corner of the parent page.  The code below is tested using JavaScript and C# in a provider-hosted app.  The basic components are as follow You have to register a custom event listener for the message event on the SharePoint page.  You can register this event on the master page so that all your App Parts can utilize the event handler You have JavaScript function that post message back to the parent On your App part post back event, you call the JavaScript to post the message back ...

SharePoint 2013 Update Access Requests Associated Owner Group

I had a requirement to programmatically change the group that handles the access requests.  Below is the code that I used to do it.  By default the access request can only be accepted/handled by the OOTB site owners group.  To change it, you need to give the SharePoint group permission to "Access Requests" list update "vti-associatedownergroup" property in the root web's AllProperties. using (SPSite site = new SPSite(siteId)) {     using (SPWeb web = site.OpenWeb())     {         try         {             SPList list = web.Lists.TryGetList("Access Requests");             if (list != null && !list.Permissions.Inherited)             {                 SPGroup oGroup = web.SiteGroups.GetByName("groupName");                 ...

SharePoint 2013 Site Provisioning with Powershell and install/upgrade App

Usually one of the biggest tasks for On-premise SharePoint development is for custom site provisioning.  Clients usually want all branding, configuration, and permission hardening done automatically when the site collection or web is created. Since Microsoft has been pushing to move away from the farm solution and suggesting App Model, a lot of techniques (such as feature event receiver) that we used to depend on cannot be used anymore.  It is a big change for On-premise SharePoint development. Here is an approach that I think will work for the App model to provision a site if the requirements are not crazy in customizing OOTB SharePoint behaviour. The solution will include A provisioning App that has AppInstalled event that handles the provision tasks such as branding, create/break permissions, create list/library ...etc (you can refer to another of my post about the branding such as master page and theme ) Powershell script that creates the site collection and inst...

SharePoint 2013 App Development Catches

When I was setting my environment for doing SharePoint 2013 development, I had a problem deploying the App by pressing F5.  I constantly getting the following error. Error occurred in deployment step 'Uninstall app for SharePoint': Cannot connect to the SharePoint site Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project. I was pretty sure the site is up and running.  So what was the problem?  It turns out that for doing SharePoint 2013 App deployment (at least for on-premise SharePoint environment), you'll need to be aware of the following: Development Catches Can’t deploy app from VS 2012 using system account Need to give the new account DBO in the following SharePoint database Config Content DB for the Developer site collection App managem...

SharePoint 2013 Branding with App using Master Page and Theme

With SharePoint 2013, Microsoft has been pushing for the App Model instead of Farm solution.  Below is sample code from a provider-hosted app that upload custom master page and theme (.spcolor) files to the SharePoint site, and apply theme through the App installed event.  The app is tested as high trust provider hosted app in a On-premise SharePoint 2013 environment. It's in C# with CSOM.  Basically, the code does the following: Upload custom master page Set custom master page Upload theme file (.spcolor) Apply Theme This is the App Event receiver class: public class AppEventReceiver : IRemoteEventService     {         public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)         {             SPRemoteEventResult result = new SPRemoteEventResult();             switch (properties.EventType)         ...