Archive | General Dev RSS for this section

Sharepoint 2013 App with Custom Lists

This post is about how to create a SharePoint 2013 App in Visual Studio 2012 with a Custom List.
To start that, you need to create an “App for SharePoint 2013” project:
CL7

Then, add a new item to your project and select “List”:

CL1

You’ll go through a wizzard where you can select if you want to create a list instance, based on an existing template, where you can’t change that template.

Or, if you want to create a list, and a template, that you can change, based on an existing template. 

Let’s start with a list based on a template that you can’t change:

CL2

Create a list named “CustomList” based on a Document Library template:

CL3

Now, let’s choose the other option and create CustomList2:

CL4

In this case, you’ll have another step, where you can define your document’s template:

CL5

And another step, where you can add more columns, in my case, I add an Attachments column:

CL6

Now, I edited my default.aspx file, to include links to my new lists:

<ahref=”/SampleApp06/Lists/CustomList”>CustomList</a>

 <ahref=”/SampleApp06/Lists/CustomList2″>CustomList2</a>

Finally, deployed my solution and see my new app with these two Custom Lists.

Create a Custom ISecureStoreProvider in Sharepoint 2013

I needed to create a custom ISecureStoreProvider in SPS 2013, to get my credentials from a custom database.

I followed this great article:

http://pholpar.wordpress.com/2012/03/13/implementing-a-simple-secure-store-provider/

The only change was that I used an empty SharePoint Project to create my project.

To set my Custom ISecureStoreProvider as the default Secure Store Provider I run in Power Shell:

[Reflection.Assembly]::LoadFrom(“C:\CustomSSSProvider\CustomSSSProvider\bin\Debug\CustomSSSProvider.dll”)
$type = [CustomSSSProvider.CustomSSSProvider]
Set-SPSecureStoreDefaultProvider –Type $type

Reference http://technet.microsoft.com/en-us/library/ff608061.aspx

Sharepoint 2013 SAP and IViewHost.aspx

If you want to show SAPIviews in your SPs 2013 Portal, and you want to have SSO you can use OOB SPS 2013.

In “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS”, you can find  “IViewHost.aspx”.

You have to configure your SAP trustedSAPHosts.config file in folder “C:\Program Files\Microsoft Office Servers\15.0\Config”

<Configuration>
<Server Name=”MYSAPSERVER”>
<ServerURL>https://sapserver:portnumber</ServerURL&gt;
<SsoAuthentication Name=”MYSAPSERVER”/>
<!– SsoAuthentication Element specifies the SSO application to use when authenticating to the SAP Server. –>
</Server>
</Configuration>

In Central Administration, create a SSO application with id “MYSAPSERVER”, and define permissions.

In your browser define, in internet options, to accept cookies from https://sapserver:portnumber.

In your SPS 2013 portal, add a PageViewrWebpart, and define the url to (change the bold text):

http://win-f9pitqqtmf3/_layouts/IViewHost.aspx?SAPHostName=MYSAPSERVER&IViewUrl=/irj/servlet/prt/portal/prtmode/preview/prtroot/pcd!3aportal_content!2f…(your transaction url)

 

The IViewHost.aspx will automatically check wich Secure Store Service application to use, and will translate your portal credentials to your sap credentials. You need to go to your SSS application  and map users credentials, for all of this work.

Sharepoint 2013 Microsoft.Office.SecureStoreService.dll

The Microsoft.Office.SecureStoreService.dll is needed if you want to programmatically retrieve credentials from SSS. In SPS 2013 (windows server 2012) you can find this dll in:

c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Office.SecureStoreService\v 4.0_15.0.0.0__71e9bce111e9429c

You can use cmd to navigate to that directory and copy the dll to use as a reference in your Visual Studio Project.

(more info:

http://msdn.microsoft.com/en-us/library/ff394459(v=office.14).aspx

http://msdn.microsoft.com/en-us/library/microsoft.office.securestoreservice.server.securestoreproviderfactory.aspx)

The sample code to retrive credentials (the applicationId is a property in my webpart and it is the value of a SSS application created in Central Administration, Secure Store Service):

private void MyWebPart_Load(object sender, EventArgs e)
 {
   if (!String.IsNullOrEmpty(applicationId))
   {
     // Get the default Secure Store Service provider.
     ISecureStoreProvider provider = SecureStoreProviderFactory.Create();
     if (provider == null)
     {
       throw new InvalidOperationException("Unable to get an ISecureStoreProvider");
     }
     ISecureStoreServiceContext providerContext = provider as       ISecureStoreServiceContext;
     providerContext.Context = SPServiceContext.Current;
     try
     {
      using (SecureStoreCredentialCollection creds = provider.GetCredentials (ApplicationId))
      {
        Debug.Assert(creds != null);

        if (creds != null)
        {
         foreach (SecureStoreCredential cred in creds)
         {
           if (cred == null)
           {
            continue;
           }

          switch (cred.CredentialType)
          {
           case SecureStoreCredentialType.UserName:
           case SecureStoreCredentialType.WindowsUserName:
           if (username == null)
           {
            username = GetStringFromSecureString(cred.Credential);
           }
           break;
           case SecureStoreCredentialType.WindowsPassword:
           case SecureStoreCredentialType.Password:
           if (password == null)
           {
            password = GetStringFromSecureString(cred.Credential);
           }
           break;
         } //switch
       }//foreach
      }//if
    }//using
   if (username == null || password == null)
   {
    throw new InvalidOperationException("Unable to get the credentials");
   }
   this.mustSetCredentials = false;
  }//try
  catch (SecureStoreException ex)
  {
    Debug.WriteLine(ex.Message);
    this.mustSetCredentials = true;
    //throw;
   }
  }
 }

 

How to install Sharepoint 2013 in a single server with sql server 2012

If you want a single server with SharePoint 2013 and SQL, if you choose a stand-alone installation, you’ll have sql server 2008 express.

If you want to use the sql server 2012, you have to install that first, and do a complete installation of SharePoint 2013.

If you don’t have a domain, when you are creating your farm, you’ll have an error, because you don´t have a domain account.

You need to create your ConfigDB, in Power Shell. Start SharePoint Power Shell as admin and run:

New-SPConfigurationDatabase

This command wil ask you for Database Name, Data Base Server, FarmCredentials and Passphrase.

After this command, you’ll see in you sql, the new config DB and SharepointAdminContentDB.

Then, you should runagain the SharePoint Configuration Wizzard, and join to na existing farm.

It’ll ask you for the PassPhrase.

Sharepoint 2013 Project Functionality

In SharePoint 2013, if you activate the site feature, Project Functionality, it’ll add a task web part to your homepage and will create a calendar and a task list.

Project Functionality

This feature adds project management functionality to a site. It includes tasks, a calendar, and web parts on the home page of the site.