Article 14 from 30 : System account can not deploy or purchase an app in SharePoint 2013 RTM

This post is article 14 from the 30 Articles App series for SharePoint

About 25 days ago , SharePoint 2013 RTM was made available to public and before few days Visual Studio 2012 Office tools Preview2 made available so now you are good to go for developing apps for RTM .

Today I will discuss about which account you should use for app deployment for on-premise environment.

I see many people are asking about the deployment issue they are getting while using System Account with SP2013 RTM.

Below is the summary of the error.

Error 1 Error occurred in deployment step ‘Install app for SharePoint’: The System Account cannot perform this action.

Cause of the error :

When you are logged in as system account (local administrator) , and you are trying to install and deploy the SharePoint app above error will appear.

This is a change in SharePoint 2013 RTM that system account are no longer supported to deploy or purchase any app from the market. It was supported in RT but it’s now prohibited because of security reason.

Woraround / Solution

  1. Create a new account in your domain let say CONTOSO/SPApp_Admin
  2. This account should be local admin
  3. This account should also be farm admin [ Farm administrator can be added from central admin -> site settings -> People -> Fram Administrator -> Add CONTOSO/SPApp_Admin ]
  4. Now login to your VM/ SharePoint Dev machine as  CONTOSO/SPApp_Admin
  5. You are good to go for deploying app to your local farm using visual studio

Hope that helps.

Article 13 from 30 : How to use Chrome Control for SharePoint app

This post is article 13 from the 30 Articles App series for SharePoint

Today, I will discuss about what is chrome control and how can you use it with SharePoint Apps?

What is Chrome Control?

Chrome Control gives the navigation header of any specific site. and so it does allow your app to show navigation header for  host-web in your app pages. User will feel familiar while browsing app-pages and the quick links to settings and host web would be handy.

It’s a great way to provide consistent SharePoint navigation into your app.

Where should you use chrome control?

The aspx pages in SharePoint-hosted app will get the top navigation by default from the master page of app web.

The html pages in sharepoint-hosted app and all pages in cloud-hosted app could use Chrome Control.

How can you use it with your SharePoint App pages?

Step -1 : place the html div place holder where you want this to be displayed.

 <div id=”divHostWebSPChrome“></div>

Step -2 : Load necessary SharePoint resources :

Load MicrosoftAjax from http://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js or you can save into your project.

Load jquery-1.7.2.min.js from http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js or you can save into your project.

Add reference to jquery-1.6.2.min.js , MicrosoftAjax.js and AppChromeControl.js (this is your custom js file) into HTML head section
Below script will go into the page itself

$(document).ready(
    function () {
        //Get the ShowChrome
        var ShowChrome = decodeURIComponent(getQueryStringParameter('ShowChrome'));

        //Get the host web url.
        var spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));

        //Build absolute path to the layouts root with the spHostUrl
        var layoutsRoot = spHostUrl + '/_layouts/15/';

        if (ShowChrome == 'Yes') {
            //Load the SP.UI.Controls.js file to render the App Chrome
            $.getScript(layoutsRoot + 'SP.UI.Controls.js', renderSPChrome);
        }
    });

Step – 3 : Render the Chrome Control
AppChromeControl.js is the file in which I have added my js script to render chrome control.

below code will go into the AppChromeControl.js

//Query String helper function
function getQueryStringParameter(urlParameterKey) {
    var params = document.URL.split('?')[1].split('&');
    var strParams = '';
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split('=');
        if (singleParam[0] == urlParameterKey)
            return singleParam[1];
    }
}

function renderSPChrome() {
// get host web logo  
 var hostlogourl = decodeURIComponent(getQueryStringParameter('SPHostLogoUrl'));
//Set the chrome options for Help, account, contact etc.
    var options = {
        'appIconUrl': hostlogourl,
        'appTitle': document.title,
        'appHelpPageUrl': 'Help.html?' + document.URL.split('?')[1],
        'settingsLinks': [
            {
                'linkUrl': 'Account.html?' + document.URL.split('?')[1],
                'displayName': 'Account settings'
            },
            {
                'linkUrl': 'Contact.html?' + document.URL.split('?')[1],
                'displayName': 'Contact us'
            }
        ]
    };

    //Load the Chrome Control into divHostWebSPChrome 
    var chromeNavigation = new SP.UI.Controls.Navigation('divHostWebSPChrome', options);
    chromeNavigation.setVisible(true);
}

If you get any trouble in rendering Chrome Control you should check the token and make sure all necessary js files are loaded .
Hope that helps.

Article 12 from 30 : How to use MVC web project for auto-hosted and provider-hosted sharepoint apps

This post is article 12 from the 30 Articles App series for SharePoint

Today, I will discuss about how you can use the MVC4 web project with your provider or Auto hosted app. And so you can take all the advantages of the latest MVC 4 features with SharePoint Apps.

1) Let’s start with auto/Provider hosted App with default template.

2) Add new project -> select web -> MVC4 web project and create.

20121119-170037.jpg

3) Add TokenHelper.cs file

20121119-170044.jpg

4) Add below references to MVC web project.

  1. Microsoft.Identity
  2. Microsoft.Identity.Extentions you can find it here : C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.IdentityModel.Extensions\v4.0_2.0.0.0__69c3241e6f0468ca\Microsoft.IdentityModel.Extensions.dll
  3. Microsoft.SharePoint.client
  4. Microsoft.SharePoint.client.runtime
  5. System.identitymodel

20121119-170050.jpg

5) Changes to web.config file:

Add appropriate clientId and client Secret under -> section.

6) Make sure that your MVC web is SSL enabled.

7) Now reference this MVC web project as remoteApp web project for your Auto/Provider Hosted App.

right click the SharePoint App project -> choose properties.

Change the property of SharePoint App project -> Web project => select above mvc web project

20121119-170056.jpg

Done. Now you can use you MVC web project with SharePoint Auto/provider hosted app.

Hope that helps..!!