Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Wednesday, 25 May 2016

SharePoint 2013 wymaga .NET 4.5, który jest już zainstalowany

Próbuję zainstalować SharePoint 2013 na Windows Server 2012 R2:



Tymczasem 4.5 już jest zainstalowane. Niestety, zainstalowane jest też Visual Studio 2015, które dostarcza .NET 4.6, a instalator SP znajdując 4.6 uznaje, że nie ma 4.5.

1.      Odinstaluj Visual Studio 2015.
2.      Znajdź zainstalowaną aktualizację KB3045563 i odinstaluj ją.

Monday, 10 August 2015

Customize Office365 suite bar links

You want to be able to disable some of those links?
1.       Go to Office 365 Home screen (https://portal.office.com/Home)
 
2.       Go to Admin > SharePoint
 
3.       Go to Settings
(or skip steps 1-3 and just type https://{your company name}-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx)
 
4.       You can now show or hide some of those links

Thursday, 23 October 2014

Mobile site - device channel configuration

1.       Go to Site collection features and activate SharePoint Server Publishing Infrastructure


2.       Go to Device Channels

3.       Create new device channel, give it alias "mobile". Under Device Inclusion Rules enter user agent substrings for devices, that should use mobile view. Check as active.

Monday, 25 November 2013

Don't use SPList.Items, use GetItems() instead

private static void GetItemsFromList()
{
    //from MDSN: It is best practice is to use one of the GetItem* methods of SPList to return a filtered collection of items.

    using (SPSite site = new SPSite(webUrl))
    {
        using (SPWeb web = site.OpenWeb())
        {
            SPList list = web.GetList(ListUrl);  //my list has 2 items
            Console.WriteLine(list.ItemCount);   //returns 2
            Console.WriteLine(list.Items.Count); //returns 0

            foreach (SPListItem item in list.Items)
            {
                // will not go inside loop, because list.Items is empty
            }

            for (int i = 0; i < list.ItemCount; i++)
            {
                var item = list.Items[i];  //will cause ArgumentOutOfRangeException
            }

            var items = list.GetItems(new SPQuery());  //returns all items
        }
    }
}

Wednesday, 7 August 2013

VPN broke my SharePoint

When I navigated to my SharePoint site, I saw this message:
This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.
The reason for this was, I installed Cisco VPN on my server in order to be able to access internal network and work with TFS (in 192.168.x.x range).
Unfortunately, SQL Server is on another private network (10.x.x.x range). And as result, it could not be found by SharePoint server.

Disconnecting from VPN solved my problem.

Monday, 29 July 2013

SharePoint social feed - how to get mentions

The article on MSDN is good starting point [1]. It shows example on how to get feed manager, make asynchronous call and retrieve newsfeed.

Instead of retrieving newsfeed, let's retrieve mentions. For this use getMentions() method[2].

In original code, while iterating, all non-normal threads were ignored. Here instead, only thread type 3 will be used [3].
Original code retrieved Text property from Thread [4]. For mentions, that would always render something like "Mentioned by John Doe". We need to go deeper in thread's properties to get actual mention text. See code example below.

Another challenge is to get URL of story. I could not find this in documentation, but was able to reverse engineer this property from raw object.
var url = thread.$2c_1;
In the end, text and url were pushed into array, so I can work with it in later and display for user in any form that is convenient.
        var mentionsArray = [];
        var mentionsCount;
        // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
        SP.SOD.executeOrDelayUntilScriptLoaded(GetFeeds, 'SP.UserProfiles.js');

        // Declare global variables.
        var clientContext;
        var feedManager;
        var mentionsFeed;

        function GetFeeds() {

            // Initialize the current client context and the SocialFeedManager instance.
            clientContext = SP.ClientContext.get_current();
            feedManager = new SP.Social.SocialFeedManager(clientContext);

            // Set parameters for the feed content that you want to retrieve.
            var feedOptions = new SP.Social.SocialFeedOptions();
            feedOptions.set_maxThreadCount(10); // default is 20

            // Change the sort order to optimize the Timeline feed results.
            feedOptions.set_sortOrder(SP.Social.SocialFeedSortOrder.byCreatedTime);
            mentionsFeed = feedManager.getMentions(false, feedOptions);     //do not clear unread mentions

            clientContext.load(feedManager);
            clientContext.executeQueryAsync(CallIterateFunctionForFeeds, RequestFailed);
        }
       function CallIterateFunctionForFeeds() {
            IterateThroughFeed(mentionsFeed);

            // Later mentionsArray will be boud by using Knockout.js ;)
            var viewModel = new AppViewModel();
            ko.applyBindings(viewModel);
        }
        function IterateThroughFeed(feed) {
            var feedOwner = feedManager.get_owner().get_name();

            // Iterate through the array of threads in the feed.
            var threads = feed.get_threads();
            mentionsCount = feed.get_unreadMentionCount();

            for (var i = 0; i < threads.length ; i++) {
                var thread = threads[i];
                var actors = thread.get_actors();

                // Use mentions. (SocialThreadType.mentionReference)
                if (thread.get_threadType() == 3) {

                    // Get the root post's author, content, and number of replies.
                    var post = thread.get_rootPost();
                    var authorName = actors[post.get_authorIndex()].get_name();
                    var postContent = post.get_text();
                    var postReference = thread.get_postReference();
                    var referencedPost = postReference.get_post();
                    var mentionText = referencedPost.get_text();

                    var url = thread.$2c_1;         //reverse engineered this name

                    mentionsArray.push({ text: postContent + " " + mentionText, url: url });
                }
            }
        }
        function RequestFailed(sender, args) {
            //not implemented
        }
MSDN Articles:
[1] Retrieve social feeds by using the SharePoint 2013 JavaScript object model http://msdn.microsoft.com/en-us/library/jj164025.aspx#bkmk_GetFeeds
[2] SP.Social.SocialFeedManager.getMentions Method http://msdn.microsoft.com/en-us/library/jj679814.aspx

Monday, 8 July 2013

Creating SharePoint 2013 on Azure VMs - checklist

Follow this checklist to create SharePoint 2013 Server with configuration database on separate Virtual Machine.
  1. Create Network in Azure
  2. After that create two VMs - first with SQL, second with SP
  3. During creating, add them both to the same Network
  4. Log into first VM - the SQL one. Add AD DS feature and promote it to domain controller
  5. Create domain user, that will be SP SQL user.
  6. Open SQL Management Studio and create login and permissions for SP SQL user
  7. Open Windows Firewall and set inbound rule for port 1433 (SQL Server)
  8. Go to Azure and create endpoint for first VM for port 1433
  9. Log into second VM - the SP one. Join it to domain.
  10. Start SP Configuration Wizard, Create new server farm, use SP SQL user to create configuration DB, configure the rest

Wednesday, 6 February 2013

Surveys in Excel with SharePoint 2013

Did you know, that you can create a survey in Excel right from SharePoint?
To be able to do this, you need to be able to create and edit Office documents in browser, so you either are using Office 365, or have Office Web Apps Server installed.

Go to document library, and when creating new document, choose Excel survey
Give it a name
Now, Excel Web App will open and display wizard.

When you add question, you have following answer types:
  • Text (one line)
  • Paragraph of text
  • Number
  • Date (unfortunately, no date picker, only textbox)
  • Time
  • Boolean value (yes/no)
  • Choice

You add as many questions you like, drag them around and arrange to your wish. When you're ready, click Share survey, and you will get a link that you can send to your frineds or collegues.

The same can be also done using consumer SkyDrive (skydrive.live.com).


Wednesday, 28 November 2012

Sync SkyDrive Pro

With SkyDrive Pro, files can be synchronized easily between PC, SharePoint library, and other devices. Necessary are:
Office 2013
SharePoint 2013 or Office 365.
This functionality was previously known as SharePoint Workspace. It 2013 version it is just much simpler.


Run SkyDrive Pro

Enter URL of what you want to sync
Click Sync Now.

After just few minutes you will see SkyDrive folder in Windows Explorer…
…that is synchronized with SharePoint

Thursday, 15 November 2012

SharePoint 2013 Look & feel in WebApp

Include these files

Copy sp.ui.controls.js from
<15 Hive>\TEMPLATE\LAYOUTS

Also, add SPHostUrl variable to query string, so address is something like:
TestPage.aspx?SPHostUrl=https%3a%2f%2fmyofficethreesixtyfive.sharepoint.com
<head runat="server">
    <title></title>
    <script src="../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/sp.ui.controls.js" type="text/javascript"></script>
    <script type="text/javascript">
        var hostweburl;
        $(document).ready(function () {
            hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            var scriptbase = hostweburl + "/_layouts/15/";
            $.getScript(scriptbase + "SP.UI.Controls.js")
        });
        function getQueryStringParameter(paramToRetrieve) {
            var queryString = document.URL.split("?")
            if (queryString.length > 1) {
                var params = queryString[1].split("&");
                var strParams = "";
                for (var i = 0; i < params.length; i++) {
                    var singleParam = params[i].split("=");
                    if (singleParam[0] == paramToRetrieve) {
                       return singleParam[1];
                    }
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div
            id="chrome_ctrl_container"
            data-ms-control="SP.UI.Controls.Navigation"
            data-ms-options='{
                "appHelpPageUrl" : "HelpPage.html",
                "appTitle" : "Diff App",
                "settingsLinks" : [
                {
                    "linkUrl" : "Page1.html",
                    "displayName" : "Navigation 1"
                },
                {
                    "linkUrl" : "Page2.html",
                    "displayName" : "Navigation 2"
                }
            ]}'>
        </div>

Snippets can be downloaded from here:
Scripts snippet
Div container snippet


Tuesday, 13 November 2012

Step-by-step: creating Remote Event Receiver

In this example I will show, how to create autohosted SharePoint 2013 app with Remote Event Receiver, and then how to deploy it to Office 365 Developer Preview.

Start with creating a list in SharePoint site, to which you will attach Event Receiver.
Go to site contents and create new Announcements list.
In Visual Studio, create new project type: App for Office 2013. For hosting type, choose autohosted.
In Solution Explorer, right-click on newly created project and choose Add > New Item. Add Remote Event Receiver


In next dialog, choose list type and which events will be handled.

You will notice, that new project has been added to your solution. This is a web service, that will be hosted outside SharePoint, on Windows Azure. SharePoint will make calls to this web service, that contain code to handle remote events.
At this step, Visual Studio has generated some boilerplate code, that you will need to extend.
Notice 'TokenHelper.cs' file. This file contains ready to use methods, to retrieve SharePointContextToken. This context token can be later used to call back to SharePoint. You can make calls to SharePoint using Client-Side Object Model (CSOM).

If you selected several different events for your list, like eg. ItemAdded, ItemUpdated, ItemDeleted, etc., they will all be handled by ProcessEvent method in web service. To be able to differentiate between various event types, use RemoteEventProperties.EventType property.

    switch (properties.EventType)
    {
        case RemoteEventType.ItemAdding:
            break;
        case RemoteEventType.ItemUpdating:
            break;
        case RemoteEventType.ItemDeleting:
            break;
        default:
            break;
   }
When you finish writing Event Receiver code, deploy it to website.
You should have already Site URL in project properties set. Select Build > Deploy Solution. Visual Studio will connect to your website, ask you for login and password and then deploy solution. You will have to confirm, that you trust this app.

More reading on MSDN:
[3] Bing Video - Remote event receivers in SharePoint 2013 demo (video tutorial for preview version of SharePoint15)

Monday, 12 November 2012

Getting started with SharePoint 2013 development - prerequisites

What you need before you start:
1. You have to get Visual Studio 2012. Previous version is not enough.
2. You need to install Office Developer Tools for Visual Studio 2012. Get it from http://go.microsoft.com/fwlink/?LinkID=261869.

Unfortunately, the installation failed.

It says right there: "ensure that all instances of Visual Studio are closed". Then try again - go to Web Platform Installer 4.0 and search for "Office".

And now, it's all working.

Remember to start Visual Studio now as administrator.

Environment for creating farm solutions with SharePoint 2013

(Update from 2022: This article is about Preview version of SharePoint 2013. It may not be relevant anymore.)

Installing my development environment, I have:
1.  Virtual Machine with Windows Server 2012
2.  SharePoint Server 2013
3.  Visual Studio 2012
I need one more element - Visual Studio Tools

Using Platform Installer, I run into problems with Workflow Client 1.0 Beta

It seems, that Workflow Client 1.0 is already installed, and it is not Beta version.

UPDATE:
On 12 November, new version of Office Tools have been announced.  When you download this file, you will notice, that the name changes from "RTMPreview" to "GA".
I strongly recommend installing this version instead. Remember to close Visual Studio during installation.