Emailing List Attachments in Office 365

Hello all! It’s been at least two years since I have posted something technical on my Salty Blog, pathetic right?. This how-to in my opinion was too good not to share as I believe that it will help others that are facing/have faced this issue.

The ability to email attachments from a list is one of those pain points that I seem to face all of the time. This documentation will take you through the process of setting up a new Flow that will grab all attachments for a single list item and will then email those attachments back out to the intended target.

Before I begin, let me preface this post stating that I did not come up with this. I found a couple of posts and podcasts but I wanted to compile this working version into one blog post.

I was searching for an answer on this issue late last year and attending one of Laura Roger’s weekly Power Hours and she presented on this. Here is a link to that original broadcast: SharePoint Power Hour: Flow Attachments & Files . If you follow the recording to the end, you will notice that Flow was not behaving properly. Well, I could not get it to work either and after a month of trying different things, I gave up.

A couple of months later I, I received an update from Microsoft’s Blog on Flow which is named Flow of the Week. This particular flow caught my eye: Send multiple attachments on a single email. I couldn’t believe it! This was exactly what the doctor ordered or at least I thought it was. I had setup the Flow as explained in the blog post but when I would run the Flow, I would receive the following message: “No input parameters provided. Please provide required input parameters ‘To’, ‘Subject’ and ‘Body'”

You’ve got to be kidding me!!!!!! Why is this not working for me?!?!?!?! I just want to send an email with the list attachments!!!!! I need this to work!!!!!

Ok, calm down……… After a couple of weeks had passed and after I tried all that I could think of to get around this error, I went back to that Microsoft blog post and noticed a comment by Vytenis Jazbutis. He explains how he was able to get around this with a “fix” for the issue of the final “send email” step. It doesn’t like and doesn’t want to add the full “file content” file from the array as an email attachment. What it wants instead is the .$content property within the file contained in the array.

I have decided to recreate the blog post showing the new way of grabbing the attachments with Vytenis’s fix. Once again, all props goes to Laura, Sunay and Vytenis of this.

With that being said, let’s dive into this and build out this Flow!

  1. Add a new “SharePoint – Create item” trigger and select the correct SharePoint Site and List.
    *** Please ensure that you already have SP List created that allows storing multiple attachments on the items in it.
  2. Add a new “Schedule – Delay” step
    *** I added this additional “Delay Step” because I was getting inconsistent results. Sometimes the trigger would fire too early and would send a blank email without grabbing the attachments. By adding this 30 second delay, it will give Flow the ability to run each step in the process before sending the email. You may not need this in your environment but in my experience even with SharePoint Designer workflows, I have to add these more often than not.
  3. Add a new “SharePoint – Get attachments” step

    *** This step will be grab all of the attachments added to the newly created list item. Use the Site name and List name from the previous step. We want to then pipe the output “ID” from the trigger, to the input ‘ID’ field.
  4. Add a new “Variables – Initialize variable” step
    *** This variable will be used to store all of the attachments in a single array.
  5. Add an “Apply to each” step.
    1. Click inside of the *Select an output box and click the “Body” output from the “Get attachments” section
    2. Click the “Add an action” button and select “SharePoint – Get attachment content”
    3. For the ID field, select the “ID” output from the “When an item is created” trigger section
    4. For the File Identifier field, select the “Id” output from the “Get attachments” section
    5. Click the “Add an action” and select “Variables – Append to array variable”
      1. For the Name field, select “attachmentArray” from the dropdown. (this was created in step 4)
      2. For the Value field, type in the following JSON statement:
        1. {
          "ContentBytes":,
          "Name":
          }
        2. For “ContentBytes”, click between the : and , and then click on the “Expression” output
        3. Type in the following expression: body(‘Get_attachment_content’).$content and click the ‘OK’ button
          *** “Get_attachment_content” is the name of the step created in 5b. Don’t forget the underscores for spaces.
      3. For “Name”, click between the ” and : and select the “DisplayName” output from the “Get attachments” section
        *** See “Note” below on additional details about the “ContentBytes” parameter
        The completed step should look like the one seen here
  6. Add a new “Office 365 Outlook – Send an email” step
    *** Note: Use whatever mail client that you have setup to run this step.

    1. Fill in all of the required fields (if applicable to your mail client).
      *** I have a list value that I am using to populate my “To” field.
    2. Click the “T” icon next to the Attachments Name field. This switch will change the attachments control from “Detail inputs for array item” to “Input the entire array”
    3. For the Attachments field, select “attachmentArray” from the “Variables” section.

  7. The completed Flow should look like the following:

Save your Flow, then go to your list and create a new list item with attachment(s) to test. Remember to be patient if you put in the delay step. You should receive an email with the attachment(s) that you added to the list item.

This solves a lot of issues that I was having and I hope that it will help you in some way.

Stay Salty!

PowerShell – Add or remove a site collection administrator from all sites

This is an issue I recently faced.  I needed to add myself as a site collection administrator to 100+ site collections.  I did not want to do this manually because it would have taken too much time.  So what did I do, I put it off until I got fed up with having to add myself manually each time I needed access.  I started searching for posts and found and excellent article on how to achieve this via PowerShell.

Here is the link to the original post: http://blog.henryong.com/2011/04/08/adding-or-removing-a-site-collection-administrator-from-all-site-collections/
This worked perfectly except for one minor detail….no progress indicator.  This is usually not that big of a deal since PowerShell takes care of business so quickly, but this time, I wanted to know where I was during each step of the process.  To do this, I added a loop counter to display the current percentage of operation.  Once the script has run, it will write back to your screen the exact number of site collections modified.

Thanks to Henry Ong over at The SharePoint Swiss Army Knife for the main script.

# This script will add a named Site Collection Administrator
# to all Site Collections within a Web Application.
#
######################## Start Variables ########################
$newSiteCollectionAdminLoginName = "domain\user"
$newSiteCollectionAdminEmail = "email@saltypc.com"
$newSiteCollectionAdminName = "Eric Kirkpatrick"
$newSiteCollectionAdminNotes = ""
$siteURL = "https://yourwebapplication" #Web Application URL
$add = 1 # 1 for adding this user, 0 to remove this user
######################## End Variables ########################
Clear-Host
$siteCount = 0
[system.reflection.assembly]::loadwithpartialname("Microsoft.SharePoint")
$site = new-object microsoft.sharepoint.spsite($siteURL)
$webApp = $site.webapplication
$allSites = $webApp.sites
######################## Write Progress Declaration ######################## 
$i = 0
foreach ($site in $allSites)
{
    $web = $site.openweb()
    $web.allusers.add($newSiteCollectionAdminLoginName, $newSiteCollectionAdminEmail, $newSiteCollectionAdminName, $newSiteCollectionAdminNotes)

    $user = $web.allUsers[$newSiteCollectionAdminLoginName]
    $user.IsSiteAdmin = $add
    $user.Update()
    $web.Dispose()
    $siteCount++

######################## Update Counter and Write Progress ########################
   $i++
   Write-Progress -Activity "Adding $newSiteCollectionAdminName to all site collections within $siteURL.  Please wait..." -status "Added: $i of $($allSites.Count)" -percentComplete (($i / $allSites.Count)  * 100)
}
$site.dispose()
write-host "Updated" $siteCount "Site Collections."

To remove someone from the site collection admins, simply change the variable $add = 1 to $add = 0.  What I did was create a separate script for removing and updated the verbage in the write progress to indicate that I was removing a user.

Stay Salty!

Cannot find the FAST site template

By default, the FAST search site template is missing.  It has to be enabled via PowerShell.  Luckily, this is a very simple process.

Perform the following steps to enable the template:

  1. Login to one of the web front ends
  2. Open the SharePoint Management Shell (PowerShell for SharePoint)
  3. Type or Copy/Paste in the following making sure to change the “Identity” to your site collection:
$site = Get-SPSite -Identity https://nameofsite.com
$site.Features.Add("5EAC763D-FBF5-4d6f-A76B-EDED7DD7B0A5")

Your output should look like the below screenshot

fastfeature

Cannot publish InfoPath custom list form

Today, I ran across an issue when I went to customize a list with InfoPath.  I clicked on the ‘Customize Form’ button and it opened the item view in InfoPath as expected.  After I made my changes I went to publish my form.  I received the following error message:

“InfoPath cannot connect to the server.  The server may be offline, your computer might not be connected to the network, or InfoPath Forms Services 2010 might not be enabled on the server.  To fix this problem, start by checking your network connection, and then try again.”

Bummer!

After going through my normal rounds of troubleshooting (permissions, InfoPath, SharePoint logs, Event Viewer), I came across another blog that had the solution (at least, it worked for my issue)

Here is the link to the blog: http://brenthafnersblog.wordpress.com/2013/01/15/cannot-publish-infopath-forms-or-cutomized-list-forms-in-sharepoint-lists-2010/

Basically, all that needs to happen is that you need to reset InfoPath Form Services for that particular site collection.  To do that, just run the following PowerShell scripts from your SharePoint server:

PS C:\> Disable-SPFeature "IPFSSiteFeatures" -url "http://Server/Sites/SiteCollection"
PS C:\> Enable-SPFeature "IPFSSiteFeatures" -url "http://Server/Sites/SiteCollection"

Make sure to update the urls for the above commands

 

Enjoy and remember to Stay Salty!

SharePoint 2010 – Hiding the Search Bar

Have you ever needed to hide the search bar on your site?  Me neither until the other day.  The page needed to be plain Jane and this was one of the requests.  Turns out, this is very simple to do.  All that you need to do is add a Content Editor Web Part (CEWP) to your page and add the following lines of code to it:

<!—-Hide Search Bar——>

<style>
 #SRSB
 {
 DISPLAY: none
 }
 </style>

<!—-Hide Search Icon—–>

<style>
 .s4-help
 {
 VISIBILITY: hidden
 }
 </style>

This code will hide both the search bar and the search icon.  It’s that simple!  Try it for yourself.

Stay Salty!

InfoPath form library tries adding new documents instead of opening form

Our current migration from MOSS to SP2013 has been interesting, needless to say.  Because I am an administrator I never see these little issues.  This is one of the latest fires I had to put out.  This popped up for different users whenever they would click on new document.   At first, I thought it was s permission issue, but that was not it.

ie8 and infopath

Turns out that this is an issue with Internet Explorer 8 (of course).  The new document +  calls a javascript function that ie8 cannot recognize.  Instead of opening the web based InfoPath form, it tries to add a document.  After testing on other systems using ie9 +, Firefox, and Chrome this is the only logical explanation.

To address this issue, I had to add a Page Viewer web part to a page and link to the opened view of the form.  Not the most elegant approach, but it works.

Stay Salty!

SharePoint 2013 site in Read only

Have you ever seen this pop up at the top of your screen in 2013?

readonly

This was just one more thing to pop up during our migration from MOSS 2007 to 2013.  Fortunately, this is not a big deal.  Here is a link to another post explaining how to clear this message and remove the locks on your site.

http://blogs.msdn.com/b/spses/archive/2013/05/16/sharepoint-2013-site-in-read-only-mode-after-an-interrupted-backup.aspx

Turns out that a backup process was kicked off this morning and was not complete when we rebooted the farm.  This left us with this nice little pink bar at the top of certain sites.  Phew!  Not a crisis, just too much migration action.

Stay Salty!

Highlight a list/library line item

I blogged on this a while back using a similar approach for MOSS 2007.  Here is a link to that post: http://saltypc.com/?p=99

Things have changed since then so here are the steps to set this up in 2013.

You will need to reference jquery for this to work.  I prefer to download the minified script and place it in a centralized location inside my farm.

  1. Add a script editor web part to the bottom of your page.
  2. Insert the following into your source:
  • <script type="text/javascript" src="http://yoursitename.com/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
     $(document).ready(function(){
      $Text = $("td.ms-cellstyle.ms-vb2:contains('Change Me')"); $Text.parent().css("background-color", "#99FF66");
     });
    </script>

Modify the Change Me to reflect the column name of your list/library.  You can also change the color to any web safe color of your choice.

To highlight mulitple column choices, simply copy the $Text line and past it below the copied line.

Example:

$Text = $(“td.ms-cellstyle.ms-vb2:contains(‘Column A)”); $Text.parent().css(“background-color”, “#FFFFFF”);

$Text = $(“td.ms-cellstyle.ms-vb2:contains(‘Column B)”); $Text.parent().css(“background-color”, “#000000”);

This comes in handy when you need to find a needle in a haystack.

 

Stay Salty!

Hiding the left nav or all navigation in SharePoint 2013

Sometimes, you will find the need to hide the left nav on a page in one of your sites.  You could always click the focus on content button, but then you have to unclick to reset for any other page you browse to.

Hiding the left nav took a little more work in MOSS 2007.  You would have to open SharePoint Designer and remove a couple of lines of code.  Well, not anymore!

To accomplish this, go to your page and edit it.  Add a Script Editor web part to any zone on your page.  Add the following script to the web part:

<style>.ms-core-sideNavBox-removeLeftMargin{ DISPLAY: none }#contentBox { margin-left: 0px }</style>

Click Ok, and you’re done!  Now, if you notice, the left margin properties are set to 0px.  You may want to increase to 5px or 10px so that your page is not eating the left hand side of your monitor 🙂

If you want to hide all navigation from your page, use this script instead:

<style>.ms-core-navigation { DISPLAY: none }#contentBox { margin-left: 0px }</style>

Stay Salty!

Downloadable content for SharePoint 2013

Found a nice little page on TechNet that I though I would share in regards to content for SharePoint 2013.

Click here access this page.