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

11/23/2015

SharePoint 2013: Hide JSLink from Team Members

This article applies to SharePoint Online, SharePoint 2013 and 2016.

 

Let's start with a couple "did you knows"…

Did you know:

  • All users with Edit and Contribute permission levels can edit the home page of your site?
  • The same users can edit or delete any page in the Site Pages library.?
  • They can also edit the web parts on that page? And use advanced options like JS Link?

As part of your SharePoint governance or best practices you may want to limit who can use some of the more advanced customization features of SharePoint 2013 and 2016. JS Link, is after all, JavaScript programming and it can cause issues for daily support and the upgrade to future versions of SharePoint.

Before we get into locking down just JS Link, let's address the "did you knows". You may want to think about changing the permissions of Site Pages, Site Assets and a few other libraries to read only for all users except for Site Owners. Those libraries really should not be open for all to edit.

 

About JS Link

JS Link is a really cool technology introduced with SharePoint 2013 to let us customize web parts, views and list forms without "un-ghosting" pages using SharePoint Designer. It lets us create a JavaScript text file, store it in a library, and then link it to a web part or a form. If you are a developer, you can also use JS Link with Site Columns and Site Content Types. One of the benefits of JS Link is that the customization file can be created once, stored in a library and then be linked into many web parts and forms. When you need a change in the future, you only need to edit a single JavaScript file and not dozens or hundreds of web parts.

For web parts, JS Link is added in the Miscellaneous section of the web part properties panel.

image

 

Hiding JS Link

As SharePoint does not have a "switch" where we can just turn off the use of JS Link, we will need to come up with a CSS or JavaScript solution. If you add the following CSS to your master page (lots of ways to do this) then the JS Link box will be hidden.

<style type="text/css">
  input[id$="_JSLink_EDITOR"] {
    display:none;
  }
  label[for$="_JSLink_EDITOR"] {
    display:none;
  }
</style>

 

While we are at it, you may also want to hide the XSL Link option too:

<style type="text/css">
  input[id$="_JSLink_EDITOR"] {
    display:none;
  }
  label[for$="_JSLink_EDITOR"] {
    display:none;
  }
  input[id$="_XslLink_EDITOR"] {
    display:none;
  }
  label[for$="_XslLink_EDITOR"] {
    display:none;
  }
</style>

 

But what about the Site Owner?

If you want some users to still be able to edit the JS Link and XSL Link options then we can give those back using a SharePoint Security Trimmed Control. You just need to pick a permission that is unique that that group of users such as Add and Customize Pages. In the example below we take away JS Link from all users, and then give it back to select users.

<style type="text/css">
  input[id$="_JSLink_EDITOR"] {
    display:none;
  }
  label[for$="_JSLink_EDITOR"] {
    display:none;
  }
  input[id$="_XslLink_EDITOR"] {
    display:none;
  }
  label[for$="_XslLink_EDITOR"] {
    display:none;
  }
</style>
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="AddAndCustomizePages"> <!-- Let owners and designers see the JSLink options --> <style type="text/css"> input[id$="_JSLink_EDITOR"] { display:inline; } label[for$="_JSLink_EDITOR"] { display:inline; } input[id$="_XslLink_EDITOR"] { display:inline; } label[for$="_XslLink_EDITOR"] { display:inline; } </style> </SharePoint:SPSecurityTrimmedControl>

 

.

10/14/2015

SharePoint Online… Where's My Tree View?

 

As you are probably aware by now… SharePoint Online is a member of the "change of the day" club. My Tree View is missing in my online sites!

In my on-premises SharePoint 2013 I can go to Settings, Site Settings and there turn on/off the Tree View navigation control.

image

 

On-line? No Tree View for me…   Oh, there it is…. Navigation Elements.

image

 

What's a "Navigation Element" anyway? If I had to rename it, I would have called it "Quick View or Tree View".

 

This is great fun for people like me who write courseware for SharePoint.   Sad smile

 

Another day… another change…………………………………

 

 

 

.

9/28/2015

SharePoint: Who can't you hide things from?

 

You just created a new subsite. You broke inheritance. You removed all of the inherited permissions. You gave only three people access.

Can anyone else see this site?

Yup…

  • Your Site Collection Administrator.
  • People granted Web Application level "super user" permission policies by the server administrators. These roles are often called "Auditors" and "Super Administrators".
  • Server administrators who have granted themselves "super user" permissions.
  • Any administrator using the farm service account. (Never a best practice.)
  • Any one who your team members have "Shared" with!  (see below)
  • The SQL Database Administrator. (we never directly query the tables… right?)

 

Site Collection Administrators

When a new Site Collection is created the server administrator can assign people to two roles named Primary Owner and Secondary Owner. These two users can see and change everything in site collection, unless some permission has been denied by Web Application level user policies.

These two Site Collection Administrators can add as many other people to the list of Site Collection Administrators as they like. Only the Primary and Secondary will receive site alert emails, all of these admins have Full Control over everything in the Site Collection. For more interesting things about these extra admins, see: http://techtrainingnotes.blogspot.com/2012/12/fun-and-games-with-site-collection.html.

 

Web Application Level "Super User" Permission Policies

Server administrators can define Web Application level policies and broadly give or remove permissions. These policies overrule anything done at the Site Collection or subsite levels. Here's a few examples:

  • Remove the "Create Subsites" permission from all users.
  • Remove the "Manage Lists" permission from everyone in the Active Directory Sales Managers group.
  • Make a user an "Auditor" with rights to see everything in the entire Web Application. Yes, everything, including permissions and everything in the Site Settings page.
  • Make a user a "Super Administrator" with the ability to change anything in the Site Collection, and even run in "stealth mode" with all changes listed as "by System Account".

 

Team Member Sharing – Members are security admins???

In SharePoint 2013 Online, users given the "Edit" permission level can share the site or anything in any list or library in the site where they have that permission level. All they have to do is click one of the many "Share" buttons or links. This one should really scare you! All they have to do is click the Share at the top of the page, and they have shared the entire site without site owner approval. If they click Share on a document or list item, then they have broken inheritance on that item, and then shared it!  The same user in SharePoint on-premises is only creating an "access request". See how to hide the share buttons here: http://techtrainingnotes.blogspot.com/2015/08/hiding-evil-sharepoint-2013-share.html

A bit odd, while the user with the "Edit" permission can "share" a full site or a single list item, then cannot share a list or library. If they guess the URL to "Permissions for this document library" they get "access denied".

SharePoint Online/Office 365 vs. On Premises:

  On Premises Online
Member clicks the site level Share button Creates an "access request" – site owner needs to approve Adds new user to the Members group with usually has the Edit permission level
Member clicks the list or library item Share button Creates an "access request" – site owner needs to approve. If approved, breaks inheritance and adds permissions for the new user. Breaks inheritance and adds permissions for the new user.
Member guesses the URL to the People and Groups page… Can only see the list of users in the groups. Can remove users from groups!

So… Consider editing the "Edit" permission level and removing the "Manage Lists" permission!

 

 

 

.

4/25/2015

SharePoint Online: Sorry, something went wrong…There is not enough space on the disk.

 

My public Office 365 subscription shares resources with many other subscriptions. Somebody must be uploading a lot of stuff today!

image

And I was not even uploading anything! Just navigating around the tenant administration pages. Hopefully in a few minutes the SharePoint Online automation will move me, or someone else, to another server…

In the mean time, refreshing the page usually works, and sometimes I just have to wait a few minutes.I am a tenant after all. I don't own the building.

.

.

9/04/2014

When is Full Control not Full Control

 

This article has three possible titles:

  • All Full Control Users are not able to see the Access Requests Link and Page
  • When is Full Control not Full Control?
  • All About Associated Groups!

 

The problem: You have a user who has Full Control, but who is not a member of the Site Owners group.

Shouldn't they be able to do anything a member of the Owners group can do? Turns out they cannot see the "Access Requests" link in Site Permissions page.

Members of the Site Owners group see:

image

While the Full Control only user sees:

image

(Just typing "Full Control only user" is weird!  "Only" has Full Control?)

 

So who can see the Access Requests Link?

Two groups of people:

  • Site Collection Administrators
  • Members of the site's associated Owners Group

Notice that "users with Full Control" is not in that list, and that the word "associated" is in there.

 

Three Magic Groups

You can create many "owners" groups and give them all Full Control and they still won't be able to see the Access Requests link. The magic owners group must be "associated" to a special property. The SharePoint web site (the SPWeb object) has three properties that identify the three default special groups: AssociatedMemberGroup, AssociatedOwnerGroup and AssociatedVisitorGroup. The group associated with the AssociatedOwnerGroup gets the "magic sauce" to let its users see the Access Requests link!

SharePoint 2007 had a nice option in the People and Groups page to set the associated groups:

image

To set the associated groups in SharePoint 2010, 2013 and Office 365 you will have to visit the page that's normally displayed when you create a new subsite with unique permissions; http://yourserver/sites/yoursite/_layouts/permsetup.aspx. This page has the title of "Set Up Groups for this Site". Here you can select from existing groups or create new groups and associate them to the three "magic groups".

image

An interesting side effect of the above page it when you add an owners group that does not have Full Control this page gives the group Full Control.

 

How to set the associated groups using PowerShell:

$web = Get-SPWeb "http://buckeyespug.maxsp2013.com";
$groups = $web.SiteGroups;
$group = $groups.GetByName("The New Owners Group");
$web.AssociatedOwnerGroup = $group;
$web.Update();

 

A C# version:

SPSite site = new SPSite("http://buckeyespug.maxsp2013.com");
SPWeb web = site.RootWeb;
SPGroupCollection groups = web.SiteGroups;
SPGroup group = groups.GetByName("The New Owners Group");
web.AssociatedOwnerGroup = group;
web.Update();

 

And for non-Developers

Visit the http://yourserver/sites/yoursite/_layouts/permsetup.aspx page!

 

Another way?

According to this article you can also directly grant permissions to the Access Requests lists. (The list won't exist until you have your first access request created.)

http://rwcchen.blogspot.com/2013/10/sharepoint-2013-update-access-requests.html

 

Auto-create the default groups

If you want to create the three default groups automatically call the SPWeb.CreateDefaultAssociatedGroups method, or if you are not a developer just visit the http://yourserver/sites/yoursite/_layouts/permsetup.aspx page.

.

9/01/2014

Office 365 / SharePoint–a Moving Target–the target is still moving!

 

More changes in Office 365 / SharePoint Online…

The Welcome menu has changed again

In SharePoint 2007 the menu for user options was called the Welcome menu and displayed the word "Welcome" follow by the user's name. In SharePoint 2010 word "Welcome" disappeared and only the user's name was displayed. (The help desk would ask the user to "click on your name".) SharePoint 2013 was the same as 2010, until recently. Now there is a picture of the user, or just a generic icon. ("Will the help desk now have to say "click your face"?)

To make room for the "face" they had to double the height of the Suite Bar. Hope this did not mess up your branding…

image

Also note the addition of Tasks. This does not take you to your SharePoint task list, it takes you to Outlook. While you are here, note the behavior of the Suite Bar when then browser is resized. Menu items disappear and are now available from the "…" menu:

image

 

No Tags and Notes for You

SharePoint Online will not support the Tags and Notes social tagging features after November 1st. Recommended replacement??? Yammer!  (I have no idea how to tag a document in a SharePoint library from within Yammer…)

You can download your existing tags and notes into a CSV file, but I have no idea what you can do with them!

The following is from this support article: https://support.office.com/Article/77851bd5-6d5e-42fe-9bf6-d7c17eeb771f

Item Description of change
Tags & Notes button on ribbon Still visible but disabled.
Note Board and Tag Cloud web parts in the web part gallery Still visible and enabled. The web parts will show up as blank when added to a page.
Note Board and Tag Cloud web parts embedded in a page Page will display a blank space in the area previously occupied by the web parts. Edit the page to remove the web parts.
Social tags Social tags will no longer appear in the tags refiner. The refiner will still display hashtags.
Tags and notes listed on personal sites The area that previously listed tags and notes will be blank.

 

Office On Demand no more…

Many users never found Office on Demand. It is a link on the user's OneDrive site that does a just in time install of an Office product and runs it as an ActiveX control. This was a handy way of using Office 2013 on a PC with an older version of Office without impacting the old install. Office on Demand can no longer be demanded ( Smile ) after November 1st.

More info and options here: http://community.office365.com/en-us/f/172/t/259931.aspx

 

 

Ready, Shoot, Aim!

 

.

10/21/2013

Cincinnati SharePoint User Group 10/24/13

 

I'll be speaking at the Cincinnati User Group this Thursday, 10/24/13. See you there!


The Cincinnati SharePoint User Group will now be meeting on the 4th Thursday of each month. The next meeting is 10/24/2013. Same location and same time, just a different day!

Speaker: Mike Smith

MVP SharePoint, Senior instructor at MAX Technical Training, Computer professional (computer nut) since 1980, Courseware author, Book author (SharePoint 2007 & 2010 Customization for the Site Owner), Speaker at SharePoint events, toy airplane pilot..

Topic: Using PowerShell, and a web service call or two, to Administer SharePoint Office 365

In this presentation we will combine the recently released SharePoint Online Management Shell PowerShell module, the Microsoft Online Services PowerShell module and a few PowerShell web services calls to management SharePoint Online. By the end of the session we will have a complete script to create a SharePoint classroom or team collaboration environment in the cloud!

We will use the Microsoft Online Services to add users, passwords and manage licenses.

We will use the SharePoint Online Management Shell to create Site Collections, add users and add groups.

We will use web services to create subsites, lists and libraries.

And of course... there will be food, door prizes and networking!

http://www.CincinnatiSPUG.org

5/09/2012

SharePoint: Preventing Content Type Changes

 

There are many good reasons to use Content Types… if you can get people to use them, and then leave them alone.   :-)

When creating a new list item based on a Content Type the user needs to select the Content Type from the New dropdown. Once selected, the Content Type should generally not be changed. Changing it is too easy as the user is offered the choice every time they edit the item.

    image  

Preventing this is pretty easy as all we need to do is hide the first row of the edit form's HTML table. The following JavaScript will do this for us and will work in both SharePoint 2007, SharePoint 2010 and SharePoint Online / Office 365:

<script>
var ttnTables = document.getElementsByTagName("TABLE")
for (var i=0;i<ttnTables.length;i++)
{
  if (ttnTables[i].className=="ms-formtable")
  {
    ttnTables[i].rows[0].style.display="none";
  }
}
</script>

 

Now the Content Type is hidden on the edit form.

    image

But can the site owner change it?

The only problem with this solution is that it also prevents the site owner from changing the Content Types. We need to only run the above code for non site owners. To do this we will use the SPSecurityTrimmedControl and set the PermissionString to a suitable value, such as ManageWeb.

<!-- default value -->
<script type="text/javascript">
  var canChangeContentType = false;
</script>

<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageWeb">
  <!--text for users who have the ManageWeb permission -->
  <script type="text/javascript">
    canChangeContentType = true;
  </script>
</SharePoint:SPSecurityTrimmedControl>

<script type="text/javascript">
if (canChangeContentType == false)
{
  var ttnTables = document.getElementsByTagName("TABLE")
  for (var i=0;i<ttnTables.length;i++)
  {
    if (ttnTables[i].className=="ms-formtable")
    {
      ttnTables[i].rows[0].style.display="none";
    }
  }
}
</script>
 

There is a workaround!

A user with permissions to create private views can create a DataSheet view with the Content Type column displayed and then edit the Content Type.

 

Where to add this code

SharePoint 2007

  1. Open SharePoint Designer and open the site with the list that uses Content Types
  2. In the Folder List pane expand Lists and your list
  3. Double-click EditForm.aspx
  4. If the HTML is not displayed, click the Code button at the bottom of the page
  5. Search for "PlaceHolderMain"
  6. Select the entire line, right-click the line and select Find Matching Tag (this should find </asp:Content>)
  7. Add the JavaScript from above just before the </asp:Content> line
  8. Save and test (remember, as a Site Owner you will always be able to see the Content Type)

SharePoint 2010

  1. Open SharePoint Designer and open the site with the list that uses Content Types
  2. In the Navigation Pane click Lists and Libraries
  3. Click the name of the list that uses Content Types
  4. In the Forms area click EditForm.aspx
  5. If the window is split into Design and Code views, click the Split button at the bottom of the window
  6. Click in the area just below the existing web part
    image
  7. You should see something similar to the following in the Code view:
    image
  8. Paste the JavaScript from above between the DIV tags
  9. Save and test (remember, as a Site Owner you will always be able to see the Content Type)

 

.

5/08/2012

Adding JavaScript and CSS to SharePoint

 

Many of my Site Owner customization tips require adding CSS and JavaScript to individual pages, the Content Editor Web Part or to the master page. Instead of repeating those steps over and over I'll link to this page in the future. (This is an expansion of an earlier article found here.)

Where to put your JavaScript or CSS

Where to put your JavaScript or CSS

Where you put the JavaScript or CSS largely depends on what it does and if it needs to interact with a single list, a single page or an entire site. Here are some possibilities:

  • Content Editor Web Part - Use a CEWP when you want to add code to a single web page that is also a web part page. (See the Web Part chapter of my book for ways to see if a page is a web part page)
     
    Features:
    • Easy to use (Source Editor in 2007 and HTML editor in 2010)
    • Easy to reuse (Exportable - see the Web Part Must Knows chapter of my book for details)
    • Can be placed directly in the web part page that needs the JavaScript or CSS
    • JavaScript or CSS can also be added by linking to a text file stored in a SharePoint library. This file can have any extension, but using .HTM will let you open the file directly into SharePoint Designer.
  • Directly in a page - Use SharePoint Designer when you want to directly edit a Basic Page, Web Part page or a site page. You can add the JavaScript inside of <SCRIPT> tags, the CSS inside of <STYLE> tags, or link to a file that contains the code. Typically add your code just before the ending content tag for PlaceHolderMain. (</asp:Content>)
  • Master Page - Use SharePoint Designer to add code to a master page when you want to code to be available on every page in a site. You can add the JavaScript inside of <SCRIPT> tags or link to a file that contains the JavaScript. Typically add your CSS just before the </HEAD> section and your JavaScript just before the </BODY> tag.

 

CSS

CSS is typically added inside of a <STYLE> block. The following will change the title of a 2007 site:

       <!—the following overrides the SharePoint ms-sitietile Core CSS class --> 
       <style type="text/css"> 
           .ms-sitetitle 
           { 
             color:blue; 
             font-size:30pt;
           } 
       </style>

 

CSS can also be stored in a file in a library and linked:

     <link rel="stylesheet" type="text/css" 
           href="/sites/training/shared documents/mycustom.css" />

 

JavaScript

JavaScript is typically added inside of a <SCRIPT> block. The following will add a border around the site's icon:

<script type="text/javascript">
var siteImage = document.getElementById('GlobalTitleAreaImage');
if (siteImage != null)
{
  siteImage.style.border = 'dashed';
}
</script>

 

JavaScript can also be stored in a file in a library and linked:

<script type="text/javascript" language="javascript" 
            src="/sites/training/shared documents/mycustom.js"></script>

 

 

The CEWP in SharePoint 2007

The CEWP in SharePoint 2007 is a simple web part that includes four options to add content:

  • a Rich Text Editor with all of the HTML editing options you might expect
  • the Edit HTML Source button (image) inside of the Rich Text Editor toolbar
  • a Source Editor that is very simple text editor, so simple you many want to use another tool to write your code, and then just copy it to the Source Editor
  • a Content Link box to link to an external file containing your code - this file would typically be stored in a library
To add a Content Editor Web Part

1. Display any web part page, click Site Actions, Edit Page then Add a web part:

    image

To edit a Content Editor Web Part

1. Click the web part's edit button then select Modify Shared Web Part, then click the Source Editor button

    image

2. Or, if you have linked to a text file, then just open that text file directly from a library, make your edits and then save. No need to open the CEWP.

Tip: You can open linked code files from within SharePoint Designer by just expanding the library's folder and double-clicking the file. You will then be able to use SharePoint Designer's JavaScript, HTML and CSS editors with their color coding and auto completion features.

Hiding the CEWP title bar

The CEWP will often be used to store code and will not need a title or title bar displayed on the page.

  • In the properties editor, expand Appearance, click the Chrome Type dropdown and select None

image

 

The CEWP in SharePoint 2010

In 2010 it’s now just called "Content Editor" and is in the Media and Content section of Add a Web Part:

    image

The page with the new web part:

    image

How do you add HTML?

When you add this web part you get a "wiki style" editor for normal rich text editing. When you use the web part's edit dropdown and click Edit Web Part you will find that the Source Editor button is gone! So how do you add your JavaScript and CSS? You could just click the HTML button in the Ribbon (image), but read on for some fun issues with this option…

    image

When you add CSS or JavaScript you may get this nice little message:

    image

Consider this trivial example:

    image

Each time you go back into the HTML editor and click OK it adds another blank line after the script tag and removes line breaks elsewhere!

    image

It has even sometimes changes the capitalization. In one of my edits it changed color:red to COLOR:red.     Who knows why…

 

The fix? Just link to your code!

Both 2007 and 2010 offer the option to link from the CEWP to a text file with your content. To avoid the problem with the random edits made by 2010 just upload a text file containing the code to a library. Then in the CEWP just click the Edit Web Part option in the dropdown and add the link to the code file. This has added benefit of using any HTML, CSS and JavaScript editor such as Visual Studio or SharePoint Designer to edit your code.

To edit a Content Editor Web Part

1. If the CEWP includes displayable text, the just click anywhere in the web part to open up the editor ribbon and start typing.

2. If you have linked to a text file, then just open that text file from the library, make your edits and then save. No need to open the CEWP during each edit, just refresh the page to see the changes.

Tip: You can open linked code files from within SharePoint Designer. Click All Files, click the "push pin" to expand the list of files, expand the library, and double-click your file. You will then be able to use SharePoint Designer's JavaScript, HTML and CSS editors with their color coding and auto completion features.

 

Reusing a Content Editor Web Part Customization

You can easily reuse many CEWP customizations by exporting the web part to a file and then uploading it into another site. As the CEWP is just a container for text (HTML, JavaScript, CSS, etc) it will have few external dependencies and should be reusable in other pages and sites.

A few watch outs:

  • If the CEWP code has an absolute URL to an image, JavaScript file or other resource, then the links will still work, as long as the users of the new site have permissions to the linked files in the original site
  • If the CEWP code has relative URLs, then the new site will need the same files stored in libraries with the same library name and file names AND the same site URL (SharePoint relative URLs are relative to the site collection, not to the subsite)

 

Direct page edits using SharePoint Designer?

Almost everything you can do with the CEWP can also be done by adding your customizations directly to the page using SharePoint Designer.

Advantages of direct page edits:

  • Edits are completely hidden from site users, especially site members as there are no web parts they can edit or delete
  • Code added directly to a SharePoint 2010 view page will not break crumb trail and view menu features (See "The CEWP in SharePoint 2010" later in this chapter)
  • SharePoint Designer's editors make writing JavaScript, HTML and CSS easier with color coding and auto completion features

Disadvantages:

  • You must use SharePoint Designer - and your company may have a policy against this
  • The page will changed from un-customized (ghosted) to customized (un-ghosted), which has a small impact on performance (See chapter 6 for more details)
  • Customizations are harder to find by the next site owner who inherits your site
  • More steps are needed for each edit

To add code directly to a page:

Add your JavaScript code between the end tag for the Web Part Zone and the end tag for the PlaceHolderMain content tag (</asp:Content). (See chapter 6 of my book - "Editing a SharePoint Page")

    image

 

Editing the Master Page

JavaScript and CSS that impacts every page in the site needs to be added to the master page. CSS will typically be added in the <HEAD> section of the page. Links to JavaScript libraries will also be added to the <HEAD> section. JavaScript blocks will typically be added just before the </BODY> tag at the end of the master page.

For CSS, your custom styles can be added just after these two controls:

    <Sharepoint:CssLink runat="server"/>
    <SharePoint:Theme runat="server"/>

 

SharePoint 2007 Steps

Steps:

  1. Open your site in SharePoint Designer 2007
  2. Expand the _catalogs folder and expand the masterpage folder
  3. Double click the master page (typically default.master)
  4. If not already selected, click the Code button at the bottom of the window
  5. For CSS and linked files find the </HEAD> tag in the page
    For JavaScript script blocks, find the </BODY> tag in the page
SharePoint 2010 Steps

Steps:

  1. Open your site in SharePoint Designer 2010
  2. In the Navigation - Site Objects pane click Master Pages
  3. Right-click your site's master page (typically v4.master) and select "Edit in Advanced Mode"
  4. If not already selected, click the Code button at the bottom of the window
  5. For CSS and linked files find the </HEAD> tag in the page
    For JavaScript script blocks, find the </BODY> tag in the page

 

When will my scripts run?

A simple embedded script like the following will run as soon as the browser loads it.

<script type="text/javascript">
  alert('hello world!');
</script>

If the script is in the middle of the page, like it would be when loaded using a Content Editor Web Part, then the script will run before the page has been fully created by the browser. Most JavaScript for SharePoint projects will need to run after the HTML that it's going to interact with has been fully loaded, and quite often, after the entire page as been loaded.

To see how to deal with JavaScript running at the wrong time in SharePoint see Chapter 5's section on "Controlling when JavaScript Runs" in my book.

3/25/2012

Names you can’t use for a SharePoint subsite!

 

 

Try to create a subsite in a publishing site named "Workflowtasks"

Error

The Web site address "/workflowtasks" is already in use.

image

 

I checked and View All Site Content does not list this subsite. But... it does list a
list named "Workflow Tasks". That should not be a problem as the URL for
lists always include "/Lists/".

http://intranet.contoso.com/Lists/Workflowtasks

So why can’t I create a subsite named “workflowtasks”? When the publishing feature is enabled it creates a special list in the root of the site (i.e. no "/Lists/") named "workflowtasks".

(Why would you ever create a subsite named “Workflowlists”?  Because in one of my SharePoint workflow classes step one of the lab said “create a subsite named “Workflowlists”!)

 

Other root level list names that cannot be used for subsites

The following is a list of a few of the names that cannot be used as subsites of a Publishing template based site:

  • Long Running Operation Status
  • Notification Pages
  • PublishedLinks
  • Quick Deploy Items
  • Relationships List
  • Reports Lists
  • ReusableContent
  • Variation Labels 

 

Other root level folder names that cannot be used for subsites

The following are names used in almost every SharePoint site for folders. Some are found in every subsite while a few are only found in top level sites.

  • _catalogs  ("Error: Site names cannot contain certain reserved words and
    cannot begin with an underscore.")
  • _cts
  • _private
  • images
  • Lists
  • m

image   image

 

Library names that exist in a site cannot be used as a subsite name

 

Error

The Web site address "/Shared Documents" is already in use"

  • Shared Documents
  • SitePages
  • etc...

Try to create a subsite named "Lists"...

Error

Cannot create a Web at "/lists" because a folder already exists at this
location.

 

To find names that are not valid as subsite names

Open your site in SharePoint Designer. In 2007 all of the folder and root level list and library names are displayed in the left panel. In 2010 click on “All Files”. (If you don’t see “All Files” then your Site Collection Administrator or you server administrator may have removed your “Allow Site Owners and Designers to See the Hidden URL structure of their Web Site” permission.)

 

A sample All Files in SharePoint Designer 2010:

image

 

.

1/22/2012

Cincinnati SharePoint User Group Lightning Round in February!

 

The Cincinnati SharePoint User Group meets the first Thursday of every month at 6:00 PM at MAX Technical Training in Mason, Ohio (directions). The next meeting is 2/2/2012.

 

Lighting Round!

February  is our "Lighting Round" meeting where everyone is welcome to submit a proposal to speak for anywhere from 5 to 15 minutes. These have been a lot of fun in the past and no matter your interest in SharePoint, there will be something interesting!  (Think “SharePoint Saturday in 90 minutes”)

If you have never spoken at a SharePoint user group meeting before, this is just about the easiest way to get started. Pick your favorite aspect of SharePoint, or the latest cool SharePoint related thing you have done, and tell us about it. You don't even need slides, and if you do create slides, you probably won't need more than five or so. Keep it short, keep it interesting and have fun! (And when you are done, you can put "User group speaker" on your resume and be well on your way to SharePoint Saturday fame!)

We are looking for topics like these:

  • administrator
  • developer
  • best practices
  • worst practices / war stories / don’t try this at home
  • end user
  • site owner
  • customization tricks
  • SharePoint Online / Office 365
  • SharePoint for small groups and / or non-profits
  • or anything interesting about SharePoint!

But… no sales pitches!

 

To get the ball rolling I will start us out with this little presentation...

How to Give Back to the SharePoint Community with a Blog and the MSDN Forums
In 10 minutes we will create a blog site, do a little customization, setup an automatic Twitter feed and configure Google Analytics so you will know if anyone is reading your blog.
In the next 5 minutes we will setup an MSDN Forums account and start answering questions!

 

Now it’s your turn!

 

Send us a one paragraph topic proposal and your estimate of presentation length. If you don’t know how to reach me or someone in the user group then just post a reply to this article with your email address and I’ll get back to you. Don’t worry about your email address as I will keep your reply unpublished and private.

 

Mike

 

p.s. If there’s anyone reading this from “vendor land” and you would like to make a door prize donation to the Cincinnati SharePoint User Group, or even sponsor a meeting, please contact me.

 

.

1/02/2012

SharePoint: Not all column types can be used in Calculated or Lookup columns (plus a trick to add back four of them!)

 

A recent question in the MSDN forums got me to looking again at the limitations on the use of certain column types in calculations or lookups. The list of column types that can be used in lookups is quite limited, but with a trick using a calculated column we can add four more to the list.

 

For my test I added all of the following columns to a custom list. These include the basic columns plus a few variations of options including each type of calculated column.

image

 

Types that work for a Calculated column

I then added a Calculated column. This is the list of fields offered for use in a calculation:

    image

Not included in this list were these columns:

    image

 

Types that work for Lookups

I then added a lookup column to another list to see which column types could be used for lookups. Here’s what shows up:

    image

The only column types available for lookups are:

    image

And when a lookup has been selected, here is the list of columns that can also be displayed from the lookup list:

    image

Or, just these types:

    image

So, these are excluded from lookups:

    image

 

A workaround for some missing lookup column types!

If you look back at the types that did show up in the list for lookup columns you will find:

    image

And if you go back to the list of types that can be used in calculated columns you will see that we can create calculated columns for some of the missing lookup types, as long as the calculation returns “Single line of text”!

With a calculation we now get to:

  Yes / No

  Choice (Drop-down or Radio Buttons, but not checkbox)

  External Data (and external data additional columns)

  Currency (but without the currency ($) symbol)

The calculation for Choice and External data is pretty straight forward:

   =[fieldname]

The currency type will just return the value, with commas and decimal points. You may want to add the currency symbol.

   =[fieldname]

or

   =”$” & [fieldname]

The Yes / No is a bit of a problem as the simple calculation just returns a 0 or 1. To get the words Yes and No you will need to do just a little more work:

  = if( [yesnofieldname], “Yes”, “No” )

Remember for all of these you will still need to set the "data type returned" to "Single line of text".

 

A few additional resources for what column types work where…

 

SharePoint Columns – Features and limitations

http://www.sharepointusecases.com/index.php/2011/07/sharepoint-columns-features-and-limitations/

 

Create list relationships by using unique and lookup columns

http://office.microsoft.com/en-us/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx

 

Column types and options

http://office.microsoft.com/en-us/sharepoint-online-enterprise-help/column-types-and-options-HA010302193.aspx?CTT=1

 

SharePoint 2007 Supported Lookup Column Types

http://sharepoint.nauplius.net/2010/09/sharepoint-2007-supported-lookup-column.html

 

.

12/29/2011

SharePoint Exams 70-667 and 70-667 Being Updated for Office 365

 

If you have been preparing for the SharePoint administrator exams, you are about to get a surprise! The exam’s web page has this little tidbit…

70-667 and 70-668 will be updated for SharePoint 2010 SP1 and Office 365 in January, 2012.
http://www.microsoft.com/learning/en/us/exam.aspx?id=70-667

They don’t list a date, so assuming January 1st…take the exam tomorrow or Saturday, or start brushing up on Office 365 and SharePoint Online.

As the web page does not have an updated “Overview” or “Sills Measured”, you may have some extra time. It would not be fair to update the exam on the 1st and not tell us what’s in it.

Post a reply if you have any news on dates…

 

.

12/24/2011

SharePoint: Displaying PDFs from a Dropdown Menu

Browsing the MSDN SharePoint forums can really bring up some interesting ideas. Recently there was a question about how to display collections of PDF files in a web page. The question included a link to an article on embedding PDFs in SharePoint 2007 by Sharon Richardson. Sharon’s approach used an <embed> tag.

The <embed> tag’s SRC attribute is not updateable by JavaScript and I did not want a hard coded PDF file. I got to playing around with this and worked up a solution that uses an <IFRAME> and borrows some JavaScript from an article I wrote a while back. The JavaScript was used to convert a Links List into an HTML dropdown list (<SELECT>). Here I will use it to convert a library into a dropdown list and a PDF viewer.

Note: Displaying PDFs in SharePoint requires two things:

  • Your users must have a PDF viewer installed that can display PDFs in a browser
  • For SharePoint 2010 your server administrator much change “Browser File Handling” from Strict to Permissive for your web application (see here and here)

Another Note: :-)   This can also display pictures from a library! Just change step 4 below to include the proper file extensions.

 

2010? 2007?

This example was tested in SharePoint 2010, but should work just fine in 2007.

 

The result should look something like this:

   image

 

Steps:

  1. Add a web part part for the document library that contains the PDFs
     
  2. Edit the web part and in the properties panel click “Edit the current view”
     
  3. In the view page select just one column:  Name (linked to document)
  4. Configure the Filter section to select your files (my example just looks for “.PDF”)
     image
     
  5. Save the view
     
  6. Open Notepad and paste the JavaScript from below
     
  7. For initial testing you may want to comment out the line that starts with “x[i].parentNode.” (just add two slashes:  “// x[i].parentNode.”) – this line hides the library web part
     
  8. Edit the “var LibrarySummaryName = ” line to add your web part’s summary name
    To find the Summary name:
    1. Display the page with the web part
    2. Use the browser’s view source option to display the page’s HTML
    3. Search for “source=” and find the title of your web part (Note be sure to include all of the text including any spaces or periods that might be at the end)
       
  9. Edit the height and width attributes of the IFRAME tag to suit your needs (In pixels or percent)
     
  10. Save the file as “PDFdrowdown.html” or similar
     
  11. Upload the Notepad file to a library (Site Pages, Site Assets, or any library you have for miscellaneous site files)
    Note: You can now click the dropdown on this document and edit the file in SharePoint Designer
     
  12. Go to the library with the script file, right-click the filename and click “Copy Shortcut” (you will paste this into the Content Editor Web Part)
     
  13. Add a Content Editor Web Part and move it below the PDF library web part (important!)
     
  14. Edit this web part an paste the URL just copied into the Content Link box
     
  15. You should now be able to test the dropdown and display PDF files in the IFRAME area
     
  16. Final steps are:
    1. if you added them, remove the comment slashed added to the “x[i].parentNode.” line
    2. Edit the Content Editor Web Part and change the “Chrome” to none to hide the web part’s title

 

Hide the Toolbar and the Scrollbars!

To hide the scroll bars, just append options to the end of the URL like this:

Before:

    PDFcontrol1.src=url;

After:

    PDFcontrol1.src=url + "#toolbar=0&navpanes=0&scrollbar=0";

Page 8 of this file has other examples of what you can do with URL parameters for PDF files: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#page=8

The results should now look like this:

image

 

 

The JavaScript

<!-- the dropdown list for the libray items -->
<br/>
Select a PDF to view:
<select name="PDFSelect" id="PDFSelect"
  onchange="javascript:LoadPDFtoIFRAME(PDFSelect.options[PDFSelect.selectedIndex].value)">
  <option>Jump to ...</option>
</select>
<br/><br/>

<iframe id="PDFiframe" src=""  height="600" width="400"></iframe>


<script>
// CEWP trick from techtrainingnotes.blogspot.com! 
// techtrainingnotes.blogspot.com/2011/12/sharepoint-displaying-pdfs-from.html

var LibrarySummaryName = "Shared Documents Share a document with the team by adding it to this document library."

function LoadPDFtoIFRAME(url)
{
    var PDFcontrol1 = document.getElementById("PDFiframe");
    PDFcontrol1.src=url
    
    // to hide the toolbar and the scroll bars change the above line to:
    // PDFcontrol1.src=url + "#toolbar=0&navpanes=0&scrollbar=0";
}


//code to hide the links list and populate the select list

//Find the library and hide it
var x = document.getElementsByTagName("TABLE") // find all of the Tables 
var Library;
var i=0;
for ( i=0; i<x.length; i++ ) 
{
  if (x[i].summary == LibrarySummaryName)
  {
    //
    Library = x[i];

    //hide the links list web part (tables in tables in tables ...)
    // Note: while testing, you may want to comment out the next line
    x[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
    break;
   } 
}

if (Library)
{
  //Copy all of the links from the link list to the select list
  var ToList = document.getElementById("PDFSelect");

  var links = Library.getElementsByTagName("A"); // find all of the links
  for ( i=0; i<links.length; i++ ) 
  {
    if (links[i].onfocus)
    {
      if (links[i].onfocus.toString().indexOf("OnLink(this)") > -1)
        { ToList.options[ToList.length]             = new Option(links[i].innerHTML, links[i].href); }
    }
  }
}
else
{
  alert("Library web part named '" + LibrarySummaryName + "' not found")
}
</script>

 

.

 

 

 

.

12/19/2011

December 2011 CU for SharePoint 2007 and 2010 has been released

 

December 2011 CU for SharePoint 2010 has been released

Go here and see the links to the details for what’s included:

http://blogs.technet.com/b/stefan_gossner/archive/2011/12/14/december-2011-cu-for-sharepoint-2010-has-been-released.aspx

 

December 2011 CU for SharePoint 2007 has been released

http://blogs.technet.com/b/stefan_gossner/archive/2011/12/17/december-2011-cu-for-sharepoint-2007-has-been-released.aspx

 

Steve Caravajal says there’s good news for Apple iPad users wanting access to SharePoint BI content:

http://blogs.msdn.com/b/scaravajal/archive/2011/12/19/sharepoint-bi-on-the-ipad.aspx

Follow the link on Steve’s page to the TechNet article with all of the details!

 

And just in case you missed the SharePoint Online November 2011 Update announcement:

http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?pID=1002

 

.

12/18/2011

SharePoint: Change the color of a web part column

 

Over in my article on color coding lists I got this question:

“Can you post a snippet of code that shows how to apply color to a particular column - the entire column (i.e., column 7)”

Well, here’s two possible solutions. And you can change anything about the column by changing the CSS. Set the text to bold, change the font family or font size, or add borders.

 

Change the color of a web part column using CSS

This is the more elegant solution, but it will not work with Internet Explorer 6, so it will not work for SharePoint 2007, or where you still have IE 6 users.

Note: the line starting with “table[“ and ending with “td + td + td” is all one line.

<style>

table[summary="Shared Documents Share a document with the team by adding it to this
document library."].ms-listviewtable tr + tr td:first-child + td + td + td { background:orange; } </style>

Steps:

  1. Add this style to a Content Editor Web Part
    or edit the page in SharePoint Designer and add it just before the end of the PlaceHoldMain area.
     
  2. Edit the text in “summary=” section to add the name of your list web part. To find the name, display the page with the web part in a browser and search for “summary=” and copy the text between the quotes.
     
  3. Edit the “td + td + td” to select your column (one td per column)
    If you want to color more than one column, copy the entire selector and adjust the number of td’s. Something like this:  (note the comma)

    table[summary="Shared Documents Share a document with the team by adding it to this document library."].ms-listviewtable tr + tr td:first-child + td + td + td ,
    table[summary="Shared Documents Share a document with the team by adding it to this document library."].ms-listviewtable tr + tr td:first-child + td + td + td + td + td  
    {
       background:orange;
    }

Change the color of a web part column using JavaScript

This solution should work for all browser versions (crossing fingers…), but you will need to test it in the browsers used by your visitors. This probably could be reduced to one line using jQuery.

Note: the line starting with “var webpartName”“ and ending with “library.” is all one line.

<script>

// from TechTrainingNotes.blogspot.com

// The web part name can be found by viewing the source of the page and
// searching for "summary="
var webpartName = "Shared Documents Share a document with the team by adding it 
to this document library."
; // first column is 0 // in SP 2010 the first column may be check boxes var columnToChange = 5; // find the web part's table var allTables = document.getElementsByTagName("TABLE"); for (var i=1;i<allTables.length;i++) { if (allTables[i].summary == webpartName) { // loop through the rows to change the column // set j=0 to include the column heading or j=1 to skip the heading var theTable = allTables[i]; for (var j=0; j<theTable.rows.length; j++) { // any style attribute of the cell can now be changed theTable.rows[j].cells[columnToChange].style.background="yellow"; } } } </script>

Steps:

  1. Add this JavaScript to a Content Editor Web Part and move the web part below the web part to add the color to
       or
    edit the page in SharePoint Designer and add the JavaScript just before the end of the PlaceHolderMain area.
     
  2. Edit the text in “webpartName =” section to add the name of your list web part. Display the page with the web part in a browser and search for “summary=” and copy the text between the quotes.
     
  3. Edit the column number to change (var columnToChange = 5; ). The first column is column 0.

    If you want to change multiple columns it might be easier to hard code the column numbers. For example, to change columns 2, 5 and 8: (remember to count from zero)

    Change:
      theTable.rows[j].cells[columnToChange].style.background="yellow";
    To:
      theTable.rows[j].cells[2].style.background="yellow";
      theTable.rows[j].cells[5].style.background="yellow";
      theTable.rows[j].cells[8].style.background="yellow";  
     
  4. To change the color of the column heading, change the FOR counter to zero:
         for (var i=0;i<allTables.length;i++)

 

 

.

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.