10/30/2015

Trick or Treat? A Day in the Life of the SharePoint Share Button…

 

Every once and a while I work a little on my next book, SharePoint 2103 Security. At the pace I'm going it may never get done. As I'm always a bit surprised at the response and disbelief I get when I tell people about the Share button, I added a chapter to the book about the Share buttons, what they do and what you can do about them. As the book may never get done… I'll click a "share" button and share part of it with you. 

 

Is the Share Button Evil? 

So how about a little demo. One of my users, Sam, thinks Susan would be interested in one of our purchase orders. Here’s a walkthrough of what Sam, Susan, a few other strangers, and the Site Owner might see.

 

Mike adds a team member to the new site

Mike, the Site Owner of a new site, adds Sam to the members group.

  1. Mike goes to Settings (gear), Site Settings, Site Permissions.
    clip_image002
  2. There he notes that this site has unique permissions, i.e., does not inherit permissions from the parent site, and that users currently only have access to the site through group membership. He also notes the “different permissions” message and checks it to see that it only applies to the MicroFeed.
     
  3. Mike adds Sam to the Team Subsite Members group. Note that the group has the default “Edit” permission level. (Sam can add, edit and delete documents, and customize and delete the entire library!)
    clip_image004

 

Along comes Sam…

Sam is browsing the Purchase Orders library and thinks Susan would be interested in one of the Purchase Orders.

  1. Sam checkmarks one of the purchase orders and clicks one of the Share buttons. (Share buttons are above the library, in the ribbon and in the “…” menus.)
    clip_image006 
  2. Susan receives an email with a link to the document. Sam got copied on the email, but the Site Owner did not.
    clip_image008

 

Susan gets an email…

Susan receives the email and out of curiosity…

  1. Susan clicks the link in the email… the document opens in Office Word Apps (now called Office Online). If the document is not supported by Office Web Apps or the browser then Susan will get a blank page with a download prompt.
    clip_image010 
  2. Susan sees the “Share” button! She clicks it and shares the file with a coworker!
    clip_image012

 

And then there's Stella…

  1. Stella clicks the link, and not knowing about the auto-save features of Office Web Apps, makes a fun edit.
    clip_image014 
  2. Not knowing about the “comments thing” she adds a couple little test comments.
    image
     
  3. Stella thinks this is kind of fun and clicks the Share button…………
     
  4. Later she sees the site name (“Team Subsite” in this demo) and clicks the link.
    clip_image018 
    As she has "Limited Access" to the site she can see the library page, and there only the document that was shared with her. While she cannot see Quick Launch or the Top Link bar, she can see other custom text and links that you may have added to the site's master page. She may also see that you have changed your site logo to a picture of your new top secret product.

 

Bad day for Mike!

  1. The next day Mike gets a phone call from the team member who created the purchase order asking “Who is Stella” and why is she making changes to my purchase orders? I thought you only granted access to this site to our team? Oh, and I’m going to talk to HR about some of the comments she added!”
        image 
  2. Mike starts doing detective work…
    1. The file has been modified. (“Gee I wish I had turned on versioning!” he says.)
    2. He checkmarks the purchase order, clicks the Share button (one of several ways to do this) and clicks Shared With, and sees “there’s a lot of sharing going on!”
         clip_image020 
    3. He notes that Sam is on the team, but has no idea who Stella or Susan are. Hoping to find who shared this file with these people, he clicks ADVANCED.
          clip_image022 
    4. But, there’s nothing there that he hadn’t already seen.
       
    5. He clicks Check Permissions, enters Stella's name and only learns that she has Limited Access. This only lets him know that she has special permissions set on some object in the site… could be one item or hundreds… and there's nothing out of the box that will list them all in one step.
          image 
    6. Sam goes to Settings, Site Settings, Site Permissions to see if there anything to be learned there.
         clip_image024 
    7. Clicking Show users he again finds that Stella and Susan have Limited Access permissions to the site.
          clip_image026 
    8. Clicking Show these items he finds he has a dozen libraries with hundreds of “shared” files, all with broken inheritance.
       
    9. Mike thinks about finding another job…
       
  3. A few days later Mike creates a new group called Managers and adds three people to the group. Later one of those people call Mike about a missing purchase order. “Hey Mike, I can see PO’s 12345, 12346, 12348, 12349, but not 12347. Did we skip a number?”
    1. With broken inheritance Mike has to remember to grant access to all broken inheritance files whenever adding new groups.
       
  4. Mike gives up, resets all of the broken inheritance (hours of work) and turns off the ability for team members to share:
        clip_image028
    He did leave “Allow access requests” for those special situations.
     
  5. If he unchecks all of the Access Request options then the Share buttons are still displayed to tempt the users, but when they click the buttons they will get this popup:
        image

    You may just want to hide those Share buttons! Take a look at this article: http://techtrainingnotes.blogspot.com/2015/08/hiding-evil-sharepoint-2013-share.html

 

And did you know…

Visitors can share! But at least it’s not automatic. When they click Share and complete the form a Sharing Request is sent to the site owner (actually the name listed in the Access Request Settings dialog box). And there’s a surprise… the new user by default gets Edit Permission Level access to the document!

The flow:

  1. Visitor user checkmarks a file, clicks Share and share the file.
  2. A popup is displayed:
        clip_image030 
  3. The site owner gets an email,
    clip_image032
    and if they go to Settings, Site Settings, Site Permissions they will see:
        clip_image034 
  4. If the site owner clicks the link in the email and approves, the user gets the Edit Permission level. If the site owner goes to Site Permissions and click the link there, they can click “…” and pick a permission.
    clip_image036

 

Takeaways…

  1. Sharing a file is easy!
     
  2. By default, team members can share any file.
     
  3. Visitors can even generate Share Requests that could result in someone else getting “Edit” permissions on the document.
     
  4. Sharing breaks inheritance and complicates future site maintenance.
     
  5. There is no audit trail. No “who done it” report.
     
  6. There are no built-in tools or reports to list everything a user has access to. (Third party tools and/or PowerShell to the rescue!)
     
  7. It can be turned off. The buttons can even be hidden with a customization.
     
  8. Having items with broken inheritance will create a lot of additional work for site owners and auditors.

 

.

Oh, and if you can't wait for the book…

Buy the 2010 book. A good 98% of it still applies to 2013. The only big things missing are the Edit Permission Level, the Share buttons and App permissions.

SharePoint 2010 Security for the Site Owner: and for Administrators and Developers!

 

 

.

10/27/2015

SharePoint: Sort and Filter on One Column While Displaying Another

This article includes both 2010 and 2013 examples.

Let's say you wanted to display a Date/Time down to the minute or second, but you wanted the column heading to filter by days or months. By default the column filter dropdown displays one each of what ever it finds in the column, or in the case of dates, the nearest day.

image

But if you want just the months or years in the dropdown, then maybe something like this:

image        image

 

It's not to hard to do in SharePoint 2010, and fairly easy in SharePoint 2013

In SharePoint 2010 we still have a fully working SharePoint Designer that can easily edit web parts. In SharePoint 2013, Designer is pretty much broken for web part work, which is just as well as we should be looking at the newest tools in 2013 for our customizations. In this example we will be using JS Link for 2013.

 

Steps for SharePoint 2010

The basic steps:

  • Create a new list named "Event Announcements".
  • Add a Date and Time column named "EventDate".
  • Add a Calculated column named "Event Date" to display a YYYY-MM version of the date that can be used to filter by month.
  • Use SharePoint Designer to display the full date in the calculated column by hand customizing the XSLT.

Note: Although the names of my columns differ only by a space, you can use any column names you like. I will use EventDate for data entry and Event Date for display.

Steps:

  1. Go to your site and create a test list. For this example an Announcements list would be a good choice.
  2. Create a new column named "EventDate". (You will enter your date data here.) 
    1. In the List ribbon click Create Column.
    2. Enter "EventDate" as the name.
    3. Set the type to Date and Time.
    4. Set Date and Time Format to Date & Time.
    5. Click OK.
  3. Create a new column named "Event Date". (This column will control the filter grouping.)
    1. In the List ribbon click Create Column.
    2. Enter "Event Date" as the name.
    3. Set the type to Calculated.
    4. Enter this formula:
         =TEXT([EventDate],"yyyy-mm")
      or for years instead of months:
         =TEXT([EventDate],"yyyy")
    5. Set The data type returned from this formula to Single line of text.
    6. Click OK.
  4. Add some sample data with dates spread across two or three different months.
     
  5. Open SharePoint Designer 2010 and open your site.
  6. Click Lists and Libraries and click your list.
  7. Find and click your view (I used All Items).
  8. If the screen is not in Split view click Split at the bottom of the screen.
  9. In the Code view pane click in the web part code. (The code without the yellow background.)
  10. In the List View Tools / Design ribbon click Customize XSLT and Customize Entire View.
    image
  11. In the design view click on any one of the dates in the EventDate column.
       image
  12. Verify the field name by looking up a few lines for FieldRef_ValueOf. My field is EventDate.
       image
  13. In the design view click on any one of the dates in the Event Date column. (the calculated column)  This will highlight a line in the Code view.
  14. Edit the "value-of" element to change from this:
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
    to this:
      <xsl:value-of select="$thisNode/@*[name()='EventDate']"/>
    Note that you are replacing the expression "current()/@Name" to the name of the field wrapped in single quotes. I.e. 'EventDate'. EventDate is column from which you want to copy the data.
  15. Save the file.
  16. Return to the browser and test the view. You can edit the view and remove the EventDate column as we only need the Event Date column.
       image

 

Steps for SharePoint 2013

The basic steps:

  • Create the test list and columns. (Same steps as for 2010)
  • Create the JS Link JavaScript file.
  • Upload or save the file to a SharePoint library.
  • Edit the view's web part and link to the JS File.

Steps:

  1. Go to your site and create a test list. For this example an Announcements list would be a good choice.
  2. Create a new column named "EventDate". (You will enter your date data here.) 
    1. In the List ribbon click Create Column.
    2. Enter "EventDate" as the name.
    3. Set the type to Date and Time.
    4. Set Date and Time Format to Date & Time.
    5. Click OK.
  3. Create a new column named "Event Date". (This column will control the filter grouping.)
    1. In the List ribbon click Create Column.
    2. Enter "Event Date" as the name.
    3. Set the type to Calculated.
    4. Enter this formula:
         =TEXT([EventDate],"yyyy-mm")
      or for years instead of months:
         =TEXT([EventDate],"yyyy")
    5. Set The data type returned from this formula to Single line of text.
    6. Click OK.
  4. Add some sample data with dates spread across two or three different months.
     
  5. Open SharePoint Designer 2013 and your site.
  6. In the Navigation area click Site Assets. (or any other library)
  7. Right-click in any empty space in the file area and select New and HTML.
  8. Right-click the new file and rename it to GroupByMonthJSLink.js (any name will do)
  9. Click the new file and then click Edit File.
  10. Select all of the HTML and delete it.
  11. Enter the JavaScript listed below.
  12. Save the file.
  13. Go to the new list.
  14. Click Settings (gear) and Edit Page.
  15. In the list’s web part click the dropdown and click Edit Web Part.
  16. In the web part properties panel expand Miscellaneous.
  17. Enter the following path into the JS Link box:
    ~site/SiteAssets/GroupByMonthJSLink.js
    Note: "~site" points to current site/subsites URL while "~sitecollection" points to the top level site's URL.
  18. Click Apply. (You should see the change to the Event Date column.)
  19. Click OK
  20. In the Page ribbon click Stop Editing.
  21. Test! You can edit the view and remove the EventDate column as we only need the Event Date column.
       image

 

The JavaScript File

(function () { 

  // do all of the setup work...
  var TTNctx = {};
  TTNctx.Templates = {}; 

  // configure the Event_x0020_Date field to copy the EventDate values 
  // into the Event_x0020_Date column
  TTNctx.Templates.Fields = { 
    "Event_x0020_Date": 
{ "View": function (ctx) {return ctx.CurrentItem.EventDate} } }; // register the override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(TTNctx); })(); // end of function

 

.

10/25/2015

SharePoint: Launch a Site Workflow from a Link or Button

The following has been tested with SharePoint 2010 and 2013…

There are a lot of questions in the various forums on how to start a Site Workflow, mostly because it is a bit hard to find in SharePoint. For those looking for only that, here's the basic steps:

Start a Site Workflow

  1. Click Site Actions (2010) or Settings (gear) (2013).
  2. Click View All Site Content (2010) or Site Contents (2013).
  3. Click Site Workflows.
  4. Click the workflow!
  5. If displayed, complete the workflow initiation form. (2010 workflows always display an Initiation Form, even if has only OK and Cancel buttons.)

 

Launching a workflow from a link, button or Quick Launch

Instead of telling your users to go find the Site Workflows page it might be better just to give them a link or button to click. All we need is to know how (and where) to copy and paste the URL or JavaScript and then how to use that to create the link.

image

In SharePoint 2010 there are only two ways to launch a Site Workflow from a link, while in SharePoint 2013 there are four!

For 2010:

SharePoint 2010 Site Workflows have two possible URLs to launch workflows, one for workflows with InfoPath forms and one for workflows with ASPX forms. The kind of form you get depends on your edition of SharePoint. For Foundation, SharePoint Designer creates ASPX forms, while for Standard and Enterprise SharePoint Designer creates InfoPath (.XSN) forms. You can force ASPX forms by disabling the hidden "OffWFCommon" feature. (See note at the end of this article.) 

For Foundation: (ASPX forms)

http://yourServer/sites/yourSite/Workflows/yourWorkflowName/yourWorkflowname.aspx?TemplateID={030c0f5b-f4be-4c32-9fe6-d1fbf18080e1}&Source=http%3A%2F%2FyourServer%2Fsites%2FyourSite%2F%5Flayouts%2Fworkflow%2Easpx

For Standard and Enterprise: (InfoPath forms)

http://yourServer/sites/yourSite/_layouts/IniWrkflIP.aspx?TemplateID={6bc58ac2-b39c-4e35-a644-43335e966291}&Source=http%3A%2F%2FyourServer%2Fsites%2FI%2F%5Flayouts%2Fworkflow%2Easpx

The GUID in the URL is the unique ID for your workflow.

 

For 2013:

SharePoint 2013 supports two kinds of workflows, 2010 and 2013. As a result we end up with three ways to launch a workflow. The first two are similar to the 2010 URLs listed above. Only SharePoint 2010 style workflows are available in Foundation. 2013 style workflows are only available in Standard and Enterprise if your server administrators have installed support for them.

For Foundation 2013 and SP 2010 style workflows: (ASPX forms)

I'm assuming (a dangerous thing to do!) that the URL is similar to 2010's. In any case we will just be copying the URL.

For Standard and Enterprise 2013 and SP 2010 style workflows: (InfoPath forms) 

https://yourServer/sites/yourSite/_layouts/15/IniWrkflIP.aspx?TemplateID={b5760949-b13a-4348-a309-65a01f8fbde7}&Source=https%3A%2F%2FyourServer%2Fsites%2FyourSite%2F%5Flayouts%2F15%2Fworkflow%2Easpx

For SharePoint 2013 workflows without initiation forms started from a JavaScript function call:

javascript:StartWorkflow4('7032d6a6-66e0-4c22-9483-2971b90b0e64', '', '')

For SharePoint 2013 workflows with or without initiation forms started from a URL:

https://yourServer/sites/yourSite/wfsvc/20a711570d0549ff83adafde04bce160/WFInitForm.aspx?TemplateID={7032d6a6-66e0-4c22-9483-2971b90b0e64}&WF4=1&Source=https%3A%2F%2FyourServer%2Fsites%2FyourSite

 

Steps to Create Links for Workflows in General

No matter with version or edition, if you are working with hyperlinks to start workflows your links will be created by copying the URL to the workflow and using it to launch the workflow from Quick Launch, an anchor tag (<A>), an INPUT tag or a BUTTON tag.

Copying the URL or JavaScript:

  1. For SharePoint 2010: Click Site Actions, View All Site Content. (or click All Site Content in the Quick Launch area)
    For SharePoint 2013: Click Settings (gear) and Site Contents. (or click Site Contents in the Quick Launch area)
  2. Click Site Workflows. (top right corner of page)
  3. Right-click the workflow and click Copy Shortcut. (or right-click the workflow, click Properties and copy the URL from there.
  4. If the copied link is a URL and not JavaScript:  (JavaScript will only be found for SharePoint 2013 style workflows that do not have an Initiation Form.)
    1. Paste the URL in to Notepad or other text editor.
    2. Remove the absolute part of the path (the http://servername). This is not required, but is a best practice.
      https://yourServerName/sites/yourSite/_layouts/15/IniWrkflIP.aspx?TemplateID={b5760949-b13a-4348-a309-65a01f8fbde7}&Source=https%3A%2F%2FyourServerName%2Fsites%2Ftraining%2F%5Flayouts%2F15%2Fworkflow%2Easpx
    3. Edit the URL after &Source to the URL where you want the user to land after starting the workflow. (Usually the same page they started from, but could be an "after the workflow instructions" page.)
      /sites/yourSite/_layouts/15/IniWrkflIP.aspx?TemplateID={b5760949-b13a-4348-a309-65a01f8fbde7}&Source=%2Fsites%2Ftraining%2FSitePages%2FFurthreInstructions%2Easpx
      Notes: %2F  = "/" and %2E = "."
    4. Copy the edited URL.

 

Adding a link via Quick Launch

I won't add all of the details here, but basically:

  • For 2010 team sites: Site Actions, Site Settings, Quick Launch
  • For 2010 publishing sites: Site Actions, Site Settings, Navigation, Current Navigation
  • For 2013 team sites: Settings (gear), Site Settings, Quick Launch
    or click EDIT LINKS in the Quick Launch area, click +link 
  • For 2013 publishing sites: Settings (gear), Site Settings, Navigation, Current Navigation

 

Adding Links via HTML

You can add custom HTML to Wiki pages, ASPX pages, Links lists and Content Editor Web Parts.

<input type="Button" onclick="window.location='yourCopiedUrlGoesHere'" value="click me">

<button type="Button" onclick="window.location='yourCopiedUrlGoesHere'" >click me</button>

<a href="yourCopiedUrlGoesHere">click me</a>

 

Adding Links via JavaScript

This option only applies to SharePoint 2013 and only for 2013 style workflows without Initiation Forms. (i.e. no user interaction before the workflow starts.) If you right-click a workflow link in Settings, Site Contents, Site Workflows (workflow.aspx), click Properties and see JavaScript instead of a URL it will probably look like this:
  javascript:StartWorkflow4('7032d6a6-66e0-4c22-9483-2971b90b0e64', '', '')

The nice thing about launching a workflow from StartWorkflow4 is that it is done using a CSOM web service call and does not cause the user to move to another page. Just click, and the workflow starts. The problem for us is that the StartWorkflow4 function is not available from every page in SharePoint. It's only available from workflow.aspx. To duplicate the code from that page you will need to add a link to a SharePoint JavaScript library and copy some JavaScript code from the workflow.aspx page.

The following assumes you are editing an ASPX page in SharePoint Designer, or you have placed the code in a text file and linked to that text file from a Content Editor Web Part.

Steps:

  1. Open SharePoint Designer 2013 and the open your site.
  2. If you are directly editing a page, open that page for editing. (You may need to click Advanced Mode in the ribbon.)
  3. If you are using a Content Editor Web Part for the code:
    1. Click Site Assets (could also use Site Pages or any other library).
    2. Right-click in the white space in the file list area and click HTML.
    3. Select all of the HTML and delete it.
  4. Add a link to the workflowservices.js library:
      <script type="text/javascript" src="/_layouts/15/sp.workflowservices.js"></script>
  5. Add a control to fire the JavaScript that you copied from the workflow page:

    <input type="Button" onclick="javascript:StartWorkflow4('7032d6a6-66e0-4c22-9483-2971b90b0e64', '', '')" value="click me">

    <button type="Button" onclick="javascript:StartWorkflow4('7032d6a6-66e0-4c22-9483-2971b90b0e64', '', '')">click me</button>

    <a href="" onclick="javascript:StartWorkflow4('7032d6a6-66e0-4c22-9483-2971b90b0e64', '', '') ; return false;">click me</a>
  6. Visit the Site Workflow page: Settings (gear), Site Contents, Site Workflows.
  7. Either use the browser's View Source command or press F12 and use the DOM explorer to view the HTML of the page.
  8. Search for StartWorkflow4.
  9. Browse backwards from there and find the previous <script… tag and copy from that <script tag to the matching </script> tag.
  10. Paste this into your SharePoint Designer file.
  11. Save the file.
  12. If you are directly editing a page, go to a browser and test the link.
  13. If you are using a Content Editor Web Part for the code:
    1. Go to the browser, navigate to the page where you would like to have the link.
    2. Edit the page.
    3. Insert a Content Editor Web Part.
    4. Edit the web part and in the properties panel enter the URL to your code page. Something like:
      https://yourServer/Sites/yourSite/SiteAssets/WorkFlowLinkCode.html
    5. Click OK in the properties panel.
    6. Save the page and test the link.

 

Enjoy!

 

 

Note: The OffWFCommon Feature

I have only done limited testing here… so buyer beware, and only do this on a test or dev farm.

I wanted to create a SharePoint Designer workflow that used ASPX forms instead of InfoPath forms as they were easier to customized for this project. I simply deactivated the OffWFCommon feature (by GUID), closed and reopened SharePoint Designer and then created a new workflow, which magically had ASPX forms. Not knowing what the side effects were, I reactivated the feature as soon as the workflow was written. This is a Site Collection level feature. As it is a hidden feature, you will need to use STSADM, PowerShell or code to activate or deactivate it.

Note: Even if it is on the server, activating this feature won't give you usable InfoPath forms on SharePoint Foundation!

Using STSADM:
   stsadm -o deactivatefeature -id C9C9515D-E4E2-4001-9050-74F980F93160 -url <url>

Using PowerShell:
   Disable-SPFeature -Identity c9c9515d-e4e2-4001-9050-74f980f93160 -url <url>

If you are curious, the feature lives here: (14 for 2010, 15 for 2013)
  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\OffWFCommon

 

.

10/23/2015

SharePoint: Set a Calculated Hyperlink Column from a Workflow

The following applies to SP 2010 and SP 2013 and should work in SP 2007.

You want a calculated column for a hyperlink, but can't create one. (you can't embed working HTML into the calculation.) So… you consider a workflow to create the data for a hyperlink column.

Some things in SharePoint are obvious, while others are not. Setting a calculated hyperlink field to a new URL from a workflow is one of the not so obvious. When you use the "Update List Item" action, click "this list", click Add and the "…" you get an Edit Hyperlink dialog box. While you can type manual text and URL entries, you can't build an expression. Your second choice is to click fx set a value from a variable. The problem is that this is not a simple string. The string in the variable needs to match this pattern, which includes a comma and one space:
    http://yoururl, your display text

 

Assumptions for the walkthrough:

  • You have a list with a course ID column named ID.
  • You have a course title column named Title.
  • You have an empty Hyperlink column named TheLink.

 

Steps:

  1. Open your site in SharePoint Designer 2010 or 2013 as appropriate.
  2. Click Lists and Libraries and click your list.
  3. Click the List Workflow button in the ribbon.
  4. Name your workflow and in SPD 2013 set the Platform Type to SharePoint 2010 or 2013 as desired..
  5. Click OK.
  6. Click the Action dropdown and click Set Workflow Variable.
    image
  7. Click workflow variable and create a new variable with a name like "LinkText", set the Type to String and click OK.
    image
  8. Click value and click the "" button.
  9. Create a string that will build your URL and your description, separated by a comma and a space. Click Add or Change Lookup to insert data from other columns. Then click OK.
    image
  10. Click the Action dropdown and click Update List Item. (for 2013: Set Field in Current Item)
    image
  11. Click this item, click Add, and select your hyperlink column. (for 2013: Click field and pick your hyperlink column and then click value and pick your variable.)
    image
  12. Click the fx button, select Workflow Variables and Parameters and then select your variable and click OK.
    image
  13. Click OK.
  14. Click Publish (in the ribbon).
  15. Test the workflow.
    1. Return to your list.
    2. Checkmark a list item.
    3. Click the ITEMS tab and click Workflows.
    4. Click the name of your workflow and click Start.
    5. Click the URL column and confirm that the link works.
  16. You will probably want to return to Designer and change the Workflow Settings to start the workflow when an item is created and when an item is changed.

 

 

.

10/17/2015

SharePoint: This service isn't available right now. User has Empty Lookup Column

 

The following screen captures are from SP 2013. SP 2010 behaves in the same way except for the error message.

 

Scenario:

  • You grant Contribute or Edit permissions to a user to a list or library, but not to the site.
  • When they visit the list/library, one column is blank that should have data.
  • When they edit an item the field is blank and the dropdown is empty.
  • When they click LIBRARY, Quick Edit, and then click the dropdown for the column the get the following error: (Clicking the link does nothing.)
        image
       Note: SP 2010 just displays an empty dropdown in the Datasheet View with no message about a "service" or other error.

    when they should be getting this:
        image

The issue? It's a look up column, and the user does not have at least Read permissions to the lookup list. (Convenient that I named it "Lookup" huh?)

Other interesting side effects of not having permissions to the lookup list:

  • If the lookup column is Required, then the user cannot edit anything in the list/library.
  • If the lookup column is not Required, then when the user edits the item, the data in the lookup column is deleted!

 

.

10/16/2015

SharePoint / PowerShell List Item Update Note

 

Sometimes it's the forests and sometimes it's the trees…

 

I have gotten so used to using shortcuts like chaining of properties in PowerShell that I forget some of my .Net fundamentals.

The Title never gets updated in this little script. What's wrong?

$web = Get-SPWeb "http://maxsp2013wfe/sites/training"
$list = $web.Lists["Announcements"]
$list.items[3]["Title"]="Test Title"
$list.items[3].Update()

Line 3 creates a new SPListItem object in RAM and sets its Title property.
Line 4 creates a new (but different) SPListItem object and calls .Update() on it.

Duh!

 

This works:

$web = Get-SPWeb "http://maxsp2013wfe/sites/training"
$list = $web.Lists["Announcements"]
$item = $list.items[3]
$item["Title"]="Test Title"
$item.Update()

Create the SPListItem object once, change a property and then save it.

And I teach this stuff!  Sad smile

.

10/15/2015

SharePoint: Two Secrets for Typing Two Letter Names

 

SharePoint 2013 took away the people picker search tool and replaced it with an autocomplete feature. Type a few letters and matching names appear.

image

The problem is that this only works when you have typed the third letter of the name. With only two letters SharePoint just sits there patiently and does nothing useful.

image

 

But there is a way…

Two secrets for two letter names...

  • Type the two letters and a space. Name will pop up.
  • Type the two letters and a semicolon. Name will be auto completed.

 

The semicolon trick also works when you have typed enough to uniquely identify a single user or group. In my farm I only have one "Robert". Typing "rob;" automatically finds him. Typing "sale;" finds and adds the "Sales" AD group.

 

 

 

.

10/14/2015

SharePoint PreCancelAction

 

SharePoint does not have a PreCancelAction. I created what I needed for one project, and present it here for your creative uses and enhancements. No warranties and no support… but the price is right!

 

PreSaveAction

When you click Save from an ASPX list form SharePoint checks to see if you have added a PreSaveAction JavaScript function to the page. If you have included the function, it is called, your code run and then your code can return a True or False to allow the save to continue, or to cancel it. You can add this function directly to the page, via a Content Editor Web Part, and in 2013 as a JS Link. Do a web search to find examples of its use.

PreSaveAction sample:

<script type="text/javascript">
 function PreSaveAction() {
  // do pre-save work here: validation, messages, etc.
  alert('Thank you for your suggestion!');
  return true;  // return true to continue with the save 
                // or return false to cancel the save
 } 
</script>

 

PreCancelAction

I needed a popup message to stress "Changes not saved", so I put together some JavaScript that intercepts the cancel and displays a message to the user. 

All of the examples below look for INPUT tags with a VALUE of "Cancel". You may want to change this line to match your language requirements. The code also only intercepts INPUT tags that include "STSNavigate" in their onclick code. This is to avoid intercepting the attachment dialog's cancel button. The code stores all of the original onclick code in a globally scoped array named TTNoriginalFunctions as each Cancel button on the form may have had unique code.

 

Warn the user on cancel:

This example does not call your functions, it just intercepts the Cancel buttons and runs the imbedded alert code.

var TTNoriginalFunctions = [];
var TTNCounts = 0;
var TTNinputs  = document.getElementsByTagName("input")
for (var i = 0; i<TTNinputs.length; i++)
{
  if (TTNinputs[i].value == "Cancel") 
  {
    if (TTNinputs[i].onclick)
    { 
      if (String(TTNinputs[i].onclick).indexOf("STSNavigate")>-1)
      {
        TTNoriginalFunctions[TTNCounts] = TTNinputs[i].onclick;
        TTNinputs[i].onclick = new Function(" return function () { alert('Changes not saved'); TTNoriginalFunctions[" + TTNCounts + "]();}")();
        TTNCounts++;
      } 
    }
  }
}

 

Callable as a function:

This is the same as the above, but wrapped up in a function that you can call it from your code. You pass in the custom code to run as a string. This uses "new Function" to build the code from a string.

var TTNoriginalFunctions = [];

function TTNPreCancelAction(yourFunctionAsString)
{
  var TTNCount = 0;
  var TTNinputs  = document.getElementsByTagName("input")
  for (var i = 0; i<TTNinputs.length; i++)
  {
    if (TTNinputs[i].value == "Cancel") 
    {
      if (TTNinputs[i].onclick)
      { 
        if (String(TTNinputs[i].onclick).indexOf("STSNavigate")>-1)
        {
          TTNoriginalFunctions[TTNCount] = TTNinputs[i].onclick;
          TTNinputs[i].onclick = new Function(" return function () { " + yourFunctionAsString + "; TTNoriginalFunctions[" + TTNCount + "]();}")();
          TTNCount++;
        } 
      }
    }
  }
}


TTNPreCancelAction("alert('changes not saved')");

 

A solution that works more like SharePoint's PreSaveAction:

You could add the TTNPreCancelAction function listed below to your master page or an existing linked JavaScript library. You can then add a PreCancelAction function to forms as needed using SharePoint Designer edits, Content Editor Web Parts or JS Link, just like the PreSaveAction functions. Your PreCancelAction function must return "true" or "false".

// Add this function to a form
function PreCancelAction()
{
  alert('Changes not saved!'); return true;
  //return confirm('Are your sure? Data will be lost!')
}


// Add this code to each form, or once in the master page.
var TTNoriginalFunctions = [];
var TTNCount = 0;
function TTNPreCancelAction()
{
    var TTNinputs  = document.getElementsByTagName("input")
    for (var i = 0; i<TTNinputs.length; i++)
    {
      if (TTNinputs[i].value == "Cancel") 
      {
        if (TTNinputs[i].onclick)
        { 
          if (String(TTNinputs[i].onclick).indexOf("STSNavigate")>-1)  // ignore the Attachments Cancel!
          {
            TTNoriginalFunctions[TTNCount] = TTNinputs[i].onclick;
            TTNinputs[i].onclick = new Function(" return function () { if ('function'==typeof(PreCancelAction)) {if (!PreCancelAction()) {return false} }; TTNoriginalFunctions[" + TTNCount + "]();}")();
            TTNCount++;
          } 
        }
      }
    }
}

TTNPreCancelAction()  //intercept the Cancel buttons
 

 

 

Have a better solution? Post a comment below!  Smile

.

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…………………………………

 

 

 

.

10/13/2015

SharePoint: 64 bit IE and Office is not generally a good idea!

 

64 bit programs have to be better than 32 bit programs, right? This is a question that keeps popping up in my classes and the various support forums, usually in the form of "xxxxx does not work in SharePoint". In general all client applications used with SharePoint should be 32 bit. This includes Word, Excel, IE, etc.  The Office ActiveX controls used with SharePoint are all 32 bit.

2010

Here's the SharePoint 2010 Browser Support article from TechNet:

https://technet.microsoft.com/en-us/library/cc288142(v=office.14).aspx

For specific things not supported in 64 bit see:

https://technet.microsoft.com/en-us/library/cc288142(v=office.14).aspx#activex

 

2013

Things have gotten better with SharePoint2013 as there's less dependence on ActiveX controls. The Office 64 bit article (https://technet.microsoft.com/en-us/library/ee681792.aspx) says "We recommend the 32-bit version of Office for most users, because it's more compatible with most other applications, especially third-party add-ins."

For SharePoint 2013 the support browsers article says it a little differently, but has the same message: "Some functionality in SharePoint 2013 requires ActiveX controls. This produces limitations on browsers which do not support ActiveX. Currently only 32-bit versions of Internet Explorer support this functionality."

https://technet.microsoft.com/en-us/library/cc263526.aspx#activex

 

 

.

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.