Collaboration-2-Go


Lösungen und Software-Entwicklung im Collaboration Umfeld, insbesondere Microsoft SharePoint, Microsoft Exchange und Microsoft Office.

Support


Mobil: +49 (152) 53 97 78 79
Mail: service@collaboration-2-go.de
Weitere Kontaktmöglichkeiten: Kontaktseite
Dekoration: Köln



Fun with JavaScript and SharePoint: View Item Permissions
Created: 01.03.2020
Categories: SharePoint 2016; SharePoint 2019; SharePoint Online/Office365; SharePoint Development; JavaScript

Without any doubts individual permissions for documents and list items are a bad idea. But sometimes it is necessary. In SharePoint those individual permissions are hard to manage. With this extension you can see the permissions in the standard view.


      
Document Library:

DocLibPermissions

Documents with inherited permissions:

Documents with inherited permissions

Documents with individual permissions:

Documents with individual permissions
      
  
Let me know if you are interested.
    

Send us a Comment!


Fun with JavaScript and SharePoint: QR Code
Created: 01.03.2020
Categories: SharePoint 2016; SharePoint 2019; SharePoint Online/Office365; SharePoint Development; JavaScript

Add a QR code to each SharePoint page using a JavaScript. If the user clicks on the button, a modal dialog pops up that shows the current url as a QR code.
  
  
Button:
  
QR code promoted action
  
  
Modal Dialog:
  
QR Code
  
Let me know if you are interested.
    

Send us a Comment!


Export und Import SPWeb with Workflows
Created: 13.11.2018
Categories: PowerShell; SharePoint Development; SharePoint 2016

      If you want to export and import a SharePoint site you can use Export-SPWeb and Import-SPWeb. In most cases these commands work fine.
  If you have SharePoint Designer Workflows in this site, SharePoint adds a folder called "Workflows" and sometime this folder has a property
  called "docid_msft_hier_listid_validate" and a value which is invalid during the import.
  
  German error message:
  Import-SPWeb : Von der Zeichenfolge dargestellte DateTime liegt außerhalb des gültigen Bereichs.
  
  The following command changes the value and an import can be executed without problems:

  
$web = Get-SPWeb -Identity https://sharepoint/sites/PowerShellTests
$folder = $web.Folders["Workflows"]
$property = $folder.Properties["docid_msft_hier_listid_validate"]

$dt = Get-Date -Year 2100 -Month 12 -Day 31
$folder.Properties["docid_msft_hier_listid_validate"] = $dt
$folder.Update()
$web.Update()
  

    

Send us a Comment!


Rename Internal Document Library Name
Created: 10.11.2018
Categories: PowerShell; SharePoint Development; SharePoint 2016

      If you want to rename a SharePoint library you can use the library configuration.
  If you want to rename the internal name you could use SharePoint Designer. Unless you have more than 5.000 items (which is a bad idea anyway):
  
  Server error: The attempted operation is prohibited because it exceeds the list view treshold enforced by the administrator.

  Ribbon
  
  But you can change the internal name using PowerShell:
  
      
    $url = "https://sharepoint/sites/PowerShellTests"
    $web = Get-SPWeb $url
    $lib = $web.GetList($web.Url + "/oldName")
    $rootFolder = $lib.RootFolder
    $rootFolder.MoveTo($web.Url + "/newName")
  

    

Send us a Comment!


Re-Apply Quotas
Created: 05.10.2017
Categories: PowerShell; SharePoint Development; SharePoint 2016

      If you change a quota template you have to re-apply the template. In this case it was very easy since all sites have the same quota (personal My Sites).

      
$wa = $get-spwebapplication "my site host url"
$wa.Sites | foreach-object {
  if ( $_.Url.StartsWith("my site host url/personal") ) {
    Set-SPSite -Identity $_.Url -QuotaTemplate "Personal Site"
  }
}

    

Send us a Comment!


Empty Popularity Trends and Most Popular Items
Created: 24.08.2017
Categories: SharePoint Development; PowerShell; SharePoint 2016

      In case the popularity trends report and the most popular items report are empty you can check (and re-eanble) the event receivers using PowerShell:

      Get receivers:
      
      $analytics = Get-SPUsageDefinition | where {
        $_.Name -like "Analytics*" }
      $pageRequests = Get-SPUsageDefinition | where {
        $_.Name -like "Page Requests" }
      


      Check receivers:
      
      $analytics.Receivers.Count
      $pageRequests.Receivers.Count
      


      If the result is 0 you can re-enable the receivers
      (remove line breaks)
      
      if ($analytics.Receivers.Count -eq 0)
      {
        $analytics.Receivers.Add(
          "Microsoft.Office.Server.Search.Applications,
          Version=16.0.0.0, Culture=neutral,
          PublicKeyToken=71e9bce111e9429c",
          "Microsoft.Office.Server.Search.Analytics.Internal.
          AnalyticsCustomRequestUsageReceiver")
      }
      if ($analytics.EnableReceivers -eq $false)
      {
        $analytics.EnableReceivers = $true
        $analytics.Update()
      }

      if ($pageRequests.Receivers.Count -eq 0)
      {
        $pageRequests.Receivers.Add(
          "Microsoft.Office.Server.Search.Applications,
          Version=16.0.0.0, Culture=neutral,
          PublicKeyToken=71e9bce111e9429c",
          "Microsoft.Office.Server.Search.Analytics.Internal.
          ViewRequestUsageReceiver")
      }
      if ($pageRequests.EnableReceivers -eq $false)
      {
        $pageRequests.EnableReceivers = $true
        $pageRequests.Update()
      }
      

    

Send us a Comment!


Download WSP Solution File from SharePoint
Created: 26.04.2017
Categories: SharePoint Development; PowerShell

      Download WSP Solution File from SharePoint

      
      $farm = Get-SPFarm
      $file = $farm.Solutions.Item("MySolution.wsp").SolutionFile
      $file.SaveAs("c:\temp\MySolution.wsp")
      

    

Send us a Comment!


Activate SharePoint TimerJob using PowerShell
Created: 20.02.2017
Categories: SharePoint Development; PowerShell

      Activate SharePoint TimerJob using PowerShell

      
      # Configuration
      $app = Get-SPWebapplication "web app url"
      $jobname = "my job name"
      $siteurl = "site url will be used within the job"

      # Install
      $job = New-Object MyNamespace.MyClass(
        $jobname, $app, $siteurl)
      $job.Schedule = [Microsoft.SharePoint.SPSchedule]::
        FromString("daily between 01:00:00 and 01:00:00")
      $job.Update()
      Restart-Service SPTimerV4

      # Check
      (Get-SPTimerJob | where-object{$_.Name -eq $jobname)}) | fl
      

    

Send us a Comment!


Access Personal Views / Do something on behalf
Created: 04.01.2016
Categories: SharePoint Development; PowerShell

      Impersonate and access personal views of somebody else.

      Code:
      
      # enter valid values
      $url = "https://sharepoint.c2go.net/sites/test"
      $listName = "MyListName"
      $login = "MyLogin"

      $web = Get-SPWeb $url
      $userid = ($web.Allusers | where-object
        { $_.LoginName -eq $login }).ID
      $user = $web.AllUsers.GetByID($userid)
      $token = $user.UserToken;
      $impSite = New-Object Microsoft.SharePoint.SPSite
        ($web.Url, $token);
      $impWeb = $impSite.OpenWeb()
      $impList = $impWeb.Lists[$listName]
      $impList.Views
      

    

Send us a Comment!


Activate Feature using CSOM
Created: 19.04.2015
Categories: SharePoint 2013; SharePoint Development

Add references to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

Code:

string url = "https://sharepoint/sites/teamsite";
string domain = "myDomain";
string login = "myLogin";
string pwd = "myPassword";
// feature id for MySite Newsfeed webpart:
Guid feature = new Guid("6928B0E5-5707-46a1-AE16-D6E52522D52B");

using (var ctx = new ClientContext(url))
{
    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
    ctx.Credentials =
      new System.Net.NetworkCredential(login, pwd, domain);
    var features = ctx.Site.Features;
    ctx.Load(features);
    ctx.ExecuteQuery();
    features.Add(feature, true, FeatureDefinitionScope.None);
    ctx.ExecuteQuery();
}


This way you I'm able to activate hidden features or start a bulk activation.
    

Send us a Comment!


SharePoint Lists and Coloured Rows
Created: 26.08.2014
Categories: SharePoint 2013; SharePoint Development

If you want to use coloured rows in SharePoint lists,

  • copy code to a file called 'HighlightRows.js'

  • Remove spaces in RenderColour between '< and a' and '< and img'
  • (stupid blog software)

  • upload file to a site collection and remember the path

  • add calculated column called 'Colour' to your list

  • Provide colour in this field, e.g. =IF(Priority="High";"rgba(255, 0,0,0.5)";IF(Priority ="medium";"rgba(255, 255,0,0.5)";"#ffffff"))

  • Include colour field in all views

  • Bind all views to JS in the ListView webpart settings, e.g. to ~sitecollection/style%20library/HighlightRows.js



Coloured SharePoint list

HighlightRows.js:

(function () {
  var overrideCtx = {};
  overrideCtx.Templates = {};
  overrideCtx.OnPostRender = [ HighlightRowOverride ];
  overrideCtx.Templates.Fields={ "Colour":{"View":RenderColour}}
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides
   (overrideCtx);
})();

function RenderColour(ctx) {
  var link = ctx.displayFormUrl +
    "&ID=" + ctx.CurrentItem.ID +
    "&source=" +
    encodeURIComponent(window.location.href);
  var text = "< a class='ms-core-suiteLink-a' href='" +
    link +
    "'>< img src='/_layouts/15/images/icgen.gif'>";
  return text;
}

function HighlightRowOverride(inCtx) {
  for (var i = 0; i < inCtx.ListData.Row.length; ++i) {
    var listItem = inCtx.ListData.Row[i];
    var iid = GenerateIIDForListItem(inCtx, listItem);
    var row = document.getElementById(iid);
    if (row != null) {
      row.style.backgroundColor = listItem.Colour;
    }
  }
  inCtx.skipNextAnimation = true;
}

    

Send us a Comment!


Add Followers to a SharePoint 2013 Site
Created: 11.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

Add Followers to a SharePoint 2013 Site using PowerShell:

$followedSite = „https://sharepoint/sites/news“
$loginName = „roloff“

$profile = $upm.GetUserProfile($loginName)
$manager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($profile)

$actorInfo = New-Object Microsoft.Office.Server.Social.SPSocialActorInfo
$actorInfo.ContentUri = $followedSite
$actorInfo.ActorType = 2 # SPSocialActorType.Site
$manager.Follow($actorInfo)

    

Send us a Comment!


Create SharePoint 2013 MySites
Created: 10.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

Create SP2013 MySites using an AD group and PowerShell:

$adGroup = ""  # AD Group with MySite users
$siteURL = ""  # any local SharePoint Site will do

$members = Get-ADGroupMember -Identity $adgroup -Recursive | sort name

# get UserProfileManager
$serviceContext  = Get-SPServiceContext -site $siteURL -ErrorAction Stop
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext) -ErrorAction Stop

foreach ($member in $members)
{
if ($upm.UserExists($member.SamAccountName))
{
  $profile = $upm.GetUserProfile($member.SamAccountName)
  $perssite = $profile.PersonalSite

  if ($perssite -eq $null)
  {
    # either this
    $profile.CreatePersonalSite(1031)  # should work in most cases
    # or this
    # $profile.CreatePersonalSiteEnque($true)  # will work in all cases; gets language from mysite host

    $perssite = $profile.PersonalSite
    if ($perssite -eq $null)
    {
      # do some error handling
    }
  }
}
}

    

Send us a Comment!


SharePoint Database Size
Created: 09.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

SharePoint Database Size using PowerShell:

Get-SPDatabase |
  where-object { $_.TypeName -eq "Content Database" } |
  select Displayname,
  @{Name="Mbytes";Expression={$_.DiskSizeRequired/ 1Mb}}


Please note: TypeName is localized, e.g. use "Inhaltsdatenbank" in a German farm.
    

Send us a Comment!


Rename SharePoint MySite Blog
Created: 16.11.2013
Categories: SharePoint 2013; SharePoint Development; PowerShell

Want to rename your MySite blogs using PowerShell since all MySite blog names are "Blog"?


# URL to your MySite web application
$MySiteWebUrl = "https://mysite.collaboration-2-go.net"
      
# where to find users in the AD
$searchbase="DC=collaboration-2-go,DC=net"
      
# required if server domain and user domain are different
$dc="my_domain_controller"
      
# required if server language is English and
# MySite language is different
$culture = "de-DE"

$webapp = Get-SPWebApplication -identity $MySiteWebUrl
[System.Threading.Thread]::CurrentThread.CurrentUICulture =
  $culture
        
foreach ($site in $webapp.Sites)
{
  # Get Active Directory Information
  $login = $site.Owner.LoginName
  if ($login.contains("\"))
  {
    $login = $login.substring($login.indexof("\") + 1)
  }
        
  $ldapfilter = "(SamAccountName=" + $login + ")"
  $aduser = Get-ADUser -LDAPFilter $ldapfilter
    -SearchBase $searchbase -Server $dc
  $displayName = $aduser.GivenName + " " + $aduser.Surname
      
  if ($displayName -eq " ")
  {
    $displayName = $site.owner.DisplayName
  }
      
  if ($site.RootWeb.WebTemplate -eq "SPSPERS") # ignore MySite host
  {
    # more sophisticated approach is possible but
    # I'm not sure about the blog URL
    foreach ($web in $site.AllWebs)
    {
      if (($web.WebTemplate -eq "BLOG") -and
        ($web.Title -eq "Blog"))
      {
        $title = "Blog von " + $displayName
        $web.Title = $title
        $web.Update()
      }
          
      $web.Dispose()
    }
  }
        
  $site.Dispose()
}

      
If you don't set the culture SharePoint changes to English title only.
    

Send us a Comment!


SharePoint Blog Layout
Created: 16.11.2013
Categories: SharePoint 2013; SharePoint Development; PowerShell

Want to apply different blog layouts using PowerShell?
      
Sample: Standard Layout:
Blog Beitrag Layout Standard

Sample: Framed Layout:
Blog Beitrag Layout Umrahmt

$web = Get-SPWeb https://sharepoint/sites/blog
write-host $web.Properties["ms-blogs-skinid"]
$web.Properties["ms-blogs-skinid"] = 1
$web.Properties.update()

Valid values for ms-blogs-skinid: 1, 2, 3
    

Send us a Comment!


Find your Worker Process
Created: 12.05.2013
Categories: Visual Studio; SharePoint Development

Find your worker process that hosts your SharePoint web application:
c:\Windows\System32\inetsrv\appcmd.exe list wp
      
Worker Process
    

Send us a Comment!


SharePoint Site Template IDs
Created: 12.11.2012
Categories: SharePoint Development

      SharePoint Site Template IDs, e.g. for stapling features:
      
      
Template NameTemplate ID
Assets Web DatabaseACCSRV#1
Charitable Contributions Web DatabaseACCSRV#3
Contacts Web DatabaseACCSRV#41
Projects Web DatabaseACCSRV#5
Issues Web DatabaseACCSRV#6
Document CenterBDR#0
Business Intelligence CenterBICenterSite#0
Publishing Site with WorkflowBLANKINTERNET#2
Publishing PortalBLANKINTERNETCONTAINER#0
BlogBLOG#0
Publishing SiteCMSPUBLISHING#0
Enterprise WikiENTERWIKI#0
Basic Meeting WorkspaceMPS#0
Blank Meeting WorkspaceMPS#1
Decision Meeting WorkspaceMPS#2
Social Meeting WorkspaceMPS#3
Multipage Meeting WorkspaceMPS#4
Records CenterOFFILE#1
Group Work SiteSGS#0
Site DirectorySPSITES#0
Personalization SiteSPSMSITE#0
My Site HostSPSMSITEHOST#0
News SiteSPSNHOME#0
Collaboration PortalSPSPORTAL#0
Report CenterSPSREPORTCENTER#0
Enterprise Search CenterSRCHCEN#0
FAST Search CenterSRCHCENTERFAST#0
Basic Search CenterSRCHCENTERLITE#0
Team SiteSTS#0
Blank SiteSTS#1
Document WorkspaceSTS#2
Visio Process RepositoryVISPRUS#0
Wiki SiteWIKI#0

      

  

Send us a Comment!


SharePoint CAML Query for Lookup Fields
Created: 27.09.2012
Categories: SharePoint 2010; SharePoint Development

      CAML query for a lookup field:
      
      <Where>
        <Eq>
          <FieldRef Name='Name' />
          <Value Type='Lookup'>Smith</Value>
        </Eq>
      </Where>
      

      CAML query for a lookup field using the ID:
      
      <Where>
        <Eq>
          <FieldRef Name='Name' LookupId='True' />
          <Value Type='Lookup'>7</Value>
        </Eq>
      </Where>
      

    

Send us a Comment!


Hide 'Delete Website' Link
Created: 07.09.2012
Categories: SharePoint Development

      If you want to hide the 'Delete Website' link you can use the following elements in a feature.
      
      Elements.xml:
      
      <?xml version="1.0" encoding="utf-8"?>
      <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <HideCustomAction
          Id="HideDeleteSPWeb"
          GroupId="SiteTasks"
          HideActionId="DeleteWeb"
          Location="Microsoft.SharePoint.SiteSettings">
        </HideCustomAction>
      </Elements>
      

      If you use MOSS2007 you have to replace
        GroupId="SiteTasks"
      by
        GroupId="SiteAdministration"
    

Send us a Comment!


SharePoint 15 Technical Preview SDK
Created: 02.02.2012
Categories: SharePoint Development

      SharePoint 15 Technical Preview Managed Object Model SDK released
    

Send us a Comment!


Workshop for SharePoint Developers finalized
Created: 23.11.2011
Categories: Collaboration-2-Go; SharePoint Development

      Workshop for SharePoint Developers is finished. Find the agenda for 4-5 days here
      (German agenda only).
    

Send us a Comment!


SharePoint Field Definitions require Braces
Created: 10.10.2011
Categories: SharePoint Development; SharePoint 2010

      SharePoint Field definitions in Elements.xml require braces, e.g.
      Field ID="{9D6556BF-D5AC-41B7-94BA-56ABE77CEDC8}"

      Otherwise you get the following error message:
      Unable to locate the xml-definition for FieldName with FieldId '9D6556BF-D5AC-41B7-94BA-56ABE77CEDC8', exception: Microsoft.SharePoint.SPException ---> System.Runtime.InteropServices.COMException (0x8000FFFF): 0x8000ffff     at Microsoft.SharePoint.Library.SPRequestInternalClass.GetGlobalContentTypeXml(String bstrUrl, Int32 type, UInt32 lcid, Object varIdBytes)…
    

Send us a Comment!