2/21/2016

Hide the Attachments Link in a SharePoint Form

 

The problem… While we do want site visitors to see the list items, we don’t want them to see or click the list’s attachments.

More SharePoint Customization tricks!
More Site Owner articles.
More articles about the SPSecurityTrimmedControl
image

One approach is to use CSS and a handy SharePoint control. You could also write a JavaScript solution. Here we will look at the CSS option.

Note: This is not security! This is hiding some HTML using CSS. Users can right-click and select View Source to discover the text hidden by the CSS.

 

General pattern:

  1. View the DispForm.aspx page (the view properties popup in SP 2010) for an item in the list.
  2. Press F12 to open the IE Developer Tools.
  3. Use the Internet Explorer F12 panel’s Select Element button to discover an appropriate tag and ID that could changed by CSS to show/hide the content.  (For this example it happens to be “idAttachmentsRow”.)
    image
  4. Edit the DispForm.aspx page using SharePoint Designer.
  5. Add CSS to hide the tag from everyone.
  6. Add a SharePoint control with additional CSS to unhide the content for users with at least the Edit permission. Set the SharePoint control to only display its content for people who can edit list items.

The SPSecurityTrimmedControl

The magic here is that the SPSecurityTrimmedControl can selectively display content based on a user’s assigned permission. As an example, users with the Read permission level do not have the EditListItems permission while members and owners do. Note that the control can only be set to a single permission, not a Permission Level or group.

More detailed steps:

  1. Open SharePoint Designer and your site.
  2. Click Lists and Libraries and your list.
  3. Click the DispForm.aspx file.
  4. In the ribbon click Advanced Mode.
  5. Find the PlaceholderMain Content tag (<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">)
  6. Add the following block of HTML just after that tag.
  7. Save your changes and test.

 

SharePoint 2010 (and probably 2007) version:

<style type="text/css">
  #idAttachmentsRow { display:none }
</style>
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="EditListItems">
  <style type="text/css">
    #idAttachmentsRow { display:inline }
  </style>
</Sharepoint:SPSecurityTrimmedControl>

SharePoint 2013 and SharePoint Online / O365 (and probably 2016) version:

<style type="text/css">
  #idAttachmentsRow { display:none !important }
</style>
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="EditListItems">
  <style type="text/css">
    #idAttachmentsRow { display:table-row !important}
  </style>
</Sharepoint:SPSecurityTrimmedControl>

A list of the PermissionsStrings can be found here: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx

More about using SPSecurityTrimmedControl can be found here: http://techtrainingnotes.blogspot.com/2009/07/sharepoint-run-javascript-based-on-user.html

 

.

2/20/2016

If you have not finished your SharePoint 2013 Dev Certs… better get to work!

 

Microsoft is “expiring” a long list of exams in September.

This means that:
  • Anyone working on the related certifications has six months to complete these exams, or never be able to finish certifications they have been working on.
  • Anyone wanting these certifications better get started ASAP.
  • Time to review your study and training plans and budgets!
  • You should review the rest of the “Expiring exams list” to see what else is going away, and check this list periodically . (dates currently range from March to Sept 2016.)
  • New certifications, exams and classes are going to be announced soon.

 

These certifications are Impacted. (The tests for them expire 9/16.)

  • MCSD: Windows Store Apps Using HTML5 (481, 482, 490)
  • MCSD: Windows Store Apps Using C# (484, 485, 491)
  • MCSD: SharePoint Applications 2013 (488, 489, 517)

These exams are going away in September:

  • 481: Essentials of Developing Windows Store Apps Using HTML5 and JavaScript
  • 482: Advanced Windows Store App Development Using HTML5 and JavaScript
  • 484: Essentials of Developing Windows Store Apps Using C#
  • 485: Advanced Windows Store App Development Using C#
  • 488: Developing SharePoint Server 2013 Core Solutions
  • 489: Developing SharePoint Server 2013 Advanced Solutions
  • 490: Recertification for MCSD: Windows® Store Apps using HTML5
  • 491: Recertification for MCSD: Windows Store Apps using C#
  • 492: Upgrade Your MCPD: Web Developer 4 to MCSD: Web Applications Examination
  • 499: Recertification for MCSD: Application Lifecycle Management
  • 517: Recertification for MCSD: SharePoint Applications

 

Links:

 

.

2/19/2016

Azure Exams 70-532, 70-533 and 70-534 Getting an Update!

 

Working on your Azure certifications? Take a break and go look at the list of announced updates. While they are listed as being updated as of March 16th, 2016, at least some the listed changes have already been applied.

The exams:

  • 70-532 Developing Microsoft Azure Solutions
  • 70-533 Implementing Microsoft Azure Infrastructure Solutions
  • 70-534 Architecting Microsoft Azure Solutions

 

The links to the exam changes PDFs:

 

.

2/17/2016

Azure Cloud – 5TB free space

 

You have to think a little differently when working in the cloud… (and sometimes I’m easily impressed with big numbers…)

  • Created an Azure Storage File Share.
  • Went to a VM running in Azure and connected to the share.
  • 5TB free space! (per share, and you only pay for what you use!)
    image

(Disclaimer: Free space on disk, not 5TB of free ($) space.)

 

image

 

Note: Azure Shares are only usable from machines running in Azure in the same region.

 

.

2/14/2016

All About Office 365 Groups

 

I’ve been collecting some notes on Office 365 Groups for my classes for a while. Here’s what I’ve got so far. Keep in mind that this feature is still evolving. Please post any corrections or updates!

 

Which Group?

SharePoint frequently reuses terms, which often makes conversations and forum posts a lot of fun. There’s at least three “Groups” in Office 365:

  • Active Directory Groups: Groups at the AD level. Outside of SharePoint. Useable across all site collections, and other applications. A “Sales Managers” AD group can be created once, updated in one place and used across all site collections in the tenant.
  • SharePoint Groups: Collections of users (people) and AD groups. Scoped to a single site collection. A “Sales Managers” SharePoint group would need to be created in each of the site collections and all updates repeated across all of the site collections.
  • Office 365 Groups: A new collaboration option! A combination of a mailbox and a site collection. Not a group useable for managing access to SharePoint sites.

 

Office 365 Groups

Office 365 Groups are a combination of an Exchange email account with the group’s name that is used to store conversations, and a “OneDrive – like” site collection to store files.

A collection of Office 365 Groups facts:

  • Internally, to distinguish traditional groups from the new Office 365 Groups, Groups are called “Unified Groups”. Externally they should be called “Office 365 Groups”, not “SharePoint Groups”.
  • Creating a Group creates an AD Distribution group, an email address and a “hidden” SharePoint Site Collection. The site collection is not visible in the tenant admin pages. The AD group is not manageable from Azure AD, only from the tenant admin Groups pages. (You can see members in Azure AD, but cannot edit them.)
  • Groups can be created from:
    • Outlook (OWA).
    • A user’s OneDrive.
    • The “GROUPS” page in the tenant Admin site. Here you can create both “Office 365 Groups” and “security groups”.
  • Conversations are stored in Exchange inboxes and files are stored in SharePoint Site Collections.
  • Groups are defined and managed in Azure AD. (Which explains why the PowerShell cmdlets for Groups are not in the SharePoint Online cmdlet library.)
  • Each user may create up to 250 Groups and can be a member of up to 1,024 Groups. There’s no limit for number of Groups per tenant.
  • Emails can be sent in the name of the group by members. (Requires a PowerShell based change.)
  • Groups will not be deleted if the Group’s owner is deleted.
  • Groups use a OneDrive for Business site under the covers. (Template: GROUP#0)
  • URL for the files site collection looks like a normal team site instead of a OneDrive site:  https://yourdomain/sites/groupsitename
  • If there is a URL conflict, a number is appended to the name: https://yourdomain/sites/groupsitename51
  • URL for the mailbox is “guessable”: https://outlook.office365.com/owa/#path=/group/yourGroupName@yourDomain.onmicrosoft.com/people
  • Groups site collections are not (currently) displayed in the admin Site Collections page. You may discover their existence when you create a new site collection that has the same name as a group site. “The site collection already exists. Please enter a different address.
  • PowerShell:
    • Get-SPOSite does not return Groups site collections, but you can access a Groups site by URL.
    • Get-SPOUser does not return users for Groups sites.
  • Groups file storage is counted against the tenant quota. It’s not considered to be a personal OneDrive. There is no “user” for the Group OneDrive. The mailbox can store up to 50GB of messages, posts and calendar entries. The SharePoint Site Collection has a max of 1TB.
  • Search: There is a search box, but it opens the Search Center in a new window/tab and searches all of SharePoint, not just the Groups file site.
  • The document library in the Group site is very much like a OneDrive for Business library. No ribbon, no custom columns, no metadata and no Content Types. The Groups library is very limited:
    • Only one library, and it’s not customizable. 
    • Can’t check out/in. (I saw this listed as a feature, but it’s not in my tenants.)
    • Versioning is enabled (Major only)
    • Cannot add/delete columns (i.e. use any custom metadata that might be useful to search or eDiscovery.)
    • Cannot use workflows.
    • Cannot audit security from the browser. 
    • No branding. Cannot be opened by SharePoint Designer.
  • The Site Collection is VERY limited.
    • Almost all of the links for site or list maintenance are redirected to the home page.
    • There is no Settings page.
    • There is no Site Permissions page, so there’s no Site Permissions page or 2nd tier recycle bin.
    • You cannot create new lists or libraries.
  • Library Sync: The Sync button works with the new OneDrive for Business sync client. So, keep in mind that group members of easily offline all of the content.
  • Recycle Bin:
    • There is a recycle bin, but you can only access the user level.
    • If you share a file with a non-member with “Edit”, they can delete the file, but get “Sorry, you don't have access to this page” when they click the Recycle Bin link.
    • There is no Site Collection recycle bin page available. The Groups “owner” can’t recover files deleted by members.
  • Can be administered and reported on from PowerShell as part of the Exchange Online cmdlets.
    https://technet.microsoft.com/en-us/library/jj200780(v=exchg.160).aspx
    cmdlets: Get/Set/New/Remove-UnifedGroup and Get/Add/Remove-UnifiedGroupLinks
    https://support.office.com/en-us/article/Use-PowerShell-to-manage-Office-365-Groups-aeb669aa-1770-4537-9de2-a82ac11b0540
  • Groups can be disabled for all users. (PowerShell)
  • Groups can be disabled for a subset of users. (Requires PowerShell.)
  • Security:
    • New groups default to “Public”. Everyone has access. You must remember to choose Private when you create the group.
    • I can’t find a place to change Public/Private status after the group has been created.
    • The names of groups are not private. They will be seen in “Send to”, “Share” and other places where user names can be seen. All groups, public and private, are listed in the “Browse Groups” screens. (Train your users not to use group names that reveal confidential data. You know, names like “IT Layoff Planning Group”. :-) )
    • Files can be shared with the “group”. They will be listed in the “Shared with us” tab.
    • Files that are shared with the “group” will be visible to all users even for Private groups! (I think this is a bug!) (The user must know the URL to the Files site.)
    • Files can be “reshared”. Sam has a site named “My Private Group”, which is Private, He shares a file with Robert (with Edit or View). Robert can only see that one file in the group site. Robert shares with Susan. Susan can then share with………
    • Users who guess the URL to the file site can see the site, but no files, or only files shared with them. They can see the list of “members” and who the owner is.

Recent Changes:

 

 

One of the more detailed articles on Office 365 Groups:
http://windowsitpro.com/office-365/exploring-office-365-groups

An Ignite 2015 session on groups:
https://channel9.msdn.com/events/Ignite/2015/BRK3114


And for fun… a less than positive view of Groups:
Office 365 Groups: The Duck-Billed Platypus of Collaboration Tools
https://futuretechnologygroup.wordpress.com/2015/08/11/office-365-groups-the-duck-billed-platypus-of-collaboration-tools/

 

Groups vs. Team Sites

  Groups Team Sites
Can add lists/libraries No Yes
Can add pages No Yes
Can add columns/metadata No Yes
Can use Content Types No Yes
Can hide membership No Yes
Can brand No Yes
Can be fully managed with PowerShell No Yes

See a pattern?

 

 

.

2/08/2016

Azure PowerShell: New-AzureRmAutomationCredential : Input string was not in a correct format.

 

Not an obvious error message:

New-AzurermAutomationCredential -AutomationAccountName "PStest" -Name "myPsredential"

New-AzurermAutomationCredential : Input string was not in a correct format.

image

Turns out it means you already have an Azure Automation credential with that name (“myPsCredential” in this example).

 

Wasted some time google/binging that one!

.

1/14/2016

Azure: PowerShell to List All Blobs in Storage

 

I have an Azure account for development and testing purposes that I want to keep as clean as possible. Part of my routine is clearing out unneeded blobs in the Storage Accounts. To do this using the Portal UI would take a long time… so PowerShell to the rescue.

I thought there would be a quick like piped command something like this:
Get-AzureStorageAccount | Get-AzureStorageContainer | Get-AzureStorageBlob

But no such luck. There’s extra steps to access the Storage Key and to create an Azure Storage Context object needed.

# optional!
$PreviousVerbosePreference = $VerbosePreference
$PreviousWarningPreference = $WarningPreference
$VerbosePreference = "SilentlyContinue"
$WarningPreference = "SilentlyContinue"


# if not alreay logged in to your Azure account...
# Add-AzureAccount
# if more than one subscription
# Select-AzureSubscription -SubscriptionName ????

Get-AzureStorageAccount |
  foreach {

    $acct = $_.label; $storageKey = (Get-AzureStorageKey -StorageAccountName $acct ).Primary;

    $ctx = New-AzureStorageContext -StorageAccountName $acct
-StorageAccountKey $storageKey;

    Get-AzureStorageContainer -Container * -Context $ctx } |

  foreach { $container = $_.Name; $_ } |

  Get-AzureStorageBlob |

  Select {$_.context.StorageAccountName}, {$container}, name,blobtype,length |

  Format-Table -autosize

# optional!
$VerbosePreference = $PreviousVerbosePreference

Select @{label="Storage Account";expression={$_.context.StorageAccountName}},
       @{label="Container";expression={$container}},
       name,
       blobtype,
       @{label="Bytes";expression={"{0,20:N0}" -f $_.length}} |

$WarningPreference = $PreviousWarningPreference

 

And if you like pretty columns then replace the Select line with this:

Select @{label="Storage Account";expression={$_.context.StorageAccountName}},
       @{label="Container";expression={$container}},
       name,
       blobtype,
       @{label="Bytes";expression={"{0,20:N0}" -f $_.length}} |

 

There’s got to be a better way to do this. So post any better solution as a comment!

 

Total storage?

Replace the Format-Table line with “Measure-Object -Property length -Sum” and you can get a file count and total bytes. (Don’t combine this with the “pretty columns” change!)

.

1/03/2016

“Unable to display this Web Part” after XSLT Customization

The following applies to SharePoint 2013, 2016 and SharePoint Online.

 

The Error

“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.”

image

The above error shows up in SharePoint 2013 and later when doing multi-level grouping with Data Form Web Parts. With the removal of many of the design features from SharePoint Designer 2013, I doubt there are too many people creating new XSLT customization. But if you are upgrading from 2010 or trying to implement a 2010 style customization then you many run into this error.

 

The Cause and the Fix

If you dig into the error logs you will find that this is reported as “Error while executing web part: System.StackOverflowException”. Turns out though that it is a timeout of the XSLT parser and has been around for quite a while. The fix is pretty easy, if you are on premises, just run a tiny PowerShell script from the SharePoint Management Shell.

image

$farm = Get-SPFarm
$farm.XsltTransformTimeOut = 10
$farm.Update()

Some of the articles say to increase it from the default of 1 second to 5 seconds. In my test environment I typically needed to increase it to 10 seconds. If you monitor the CPU on the server you will see that at least on lab-type virtual machines that a page load where you have this issue does put quite a load on the CPU.

SharePoint Online?  No joy for you! It appears that the default is 1 second, and you can’t change it.

 

There’s been a number of articles on the topic, mostly in the SP 2010 world:

http://thechriskent.com/tag/xslttransformtimeout/

http://blogs.msdn.com/b/joerg_sinemus/archive/2012/03/07/xslt-and-timeout-problem-when-transforming-runs-more-than-one-second.aspx

and many more: http://www.bing.com/search?q=xslttransformtimeout+sharepoint

 

.

1/01/2016

Views.Add() Cannot find an overload for "Add" and the argument count: "8".

 

I wrote a PowerShell script to create views. It worked in PowerShell 3 on SharePoint 2013. It failed in PowerShell 2 on SharePoint 2010.

To play it safe, I copied values from an existing view to insure the correct data types…

$web = Get-SPWeb http://sharepoint/sites/training
$list = $web.lists["Announcements22"]
$v = $list.views[0]
$list.Views.add("TestView",$v.ViewFields,$v.query,30,$true,$false,$v.Type,$false)

image

As I can count to 8 (usually) and I made sure the data types were correct, I then wasted a lot of time google/binging the error message.

So I then did the obvious thing for a developer, I fired up Visual Studio. And… found that there’s a datatype weirdness on the ViewFields parameter! The Add method is expecting System.Collections.Specialized.StringCollection while the View object actually returns Microsoft.SharePoint.SPViewFieldCollection.

The type conversion works in PowerShell 3:

image

But does not work in PowerShell 2:

image

 

My workaround? 

Use a handy method built into the Microsoft.SharePoint.SPViewFieldCollection type: ToStringCollection().

image

I could also have created the StringCollection object and copied the strings over using ForEach.

image

 

So why did it work in PowerShell 3 and not PowerShell 2? No idea! I’m guessing the “smarts” behind type conversion has improved. While the two collection objects are different (SPViewFieldCollection includes a .View property), the Items collection of both contain simple Strings.

 

.

12/30/2015

SharePoint – Adding Dropdown Menus without the Publishing Feature

 

The following works in SharePoint 2013, 2016 (beta 2) and SharePoint Online.

 

One of the common reasons to enable the Publishing Feature was to get the Navigation page so you could have dropdowns in the Top Link bar. Turns out that in 2013 and later you can do this without the Publishing Feature.

The Trick!

The trick is drag and drop. Starting with SharePoint 2013 you have an “EDIT LINKS” button on the page. (No Top Link Bar or Navigation page needed!)

image

When you click EDIT LINKS you can add a new item to the menu by clicking the (+) button.

image

Then there’s the trick! Drag the new link just under the parent link. (I’ll drag this one under the “Subsite1” link.)

image

image

Click Save and now you have dropdowns!

image

 

What you don’t get…

The Publishing feature Navigation page lets you select options like Open in New Window and Audience selection.

But if all you need are some dropdowns…

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.