MS Flow and Trello Integration

MS Flow allows you to create automated workflows between your favorite apps and services to get notifications, synchronize files, collect data, and more.

Trello is a web-based Project Management application. It is incredibly flexible and easy to use. It keeps track of everything from big picture to the minute details.

This article assumes that you already have MS flow account and Trello account.

MS Flow connectors:

MS Flow provides around 72 connectors which make connecting to various Apps such as SharePoint, Office 365, Twitter, Facebook, SQL, Google Calendar and many more. To get full list of available connectors, visit https://flow.microsoft.com/en-us/services/

Trello data can also be accessed using Trello connector. In this article we are going to explore the same.

Connect Trello to MS Flow:

  • Create a SharePoint List with Name “Trello”. Rename “Title” field to “Card Name” and add a new column with Single Line of Text with Name “CardDescription”. Rename it to “Card Description” afterwards.
  • Access MS flow from Office 365 app launcher or visit https://flow.microsoft.com/en-us/
  • Click on “My Flows” from top navigation
  • Click on “Create from Blank” as we will be starting from scratch
  • In the next screen you will see a list of all available actions to choose from. Type in “Trello” in the search box to get options of operations available with Trello3
  • It would ask you to Sign in to create connection to Trello. Click on “Sign In” and enter your credentials.
  • Once you enter your credentials, it will ask for permissions as below:5
  • Select “MS Flow Test” board from the list9
  • Click on “New Step” and Select “Add An Action”. Select “SharePoint – Create Item” action from search list.
  • In “Site URL” textbox, enter SharePoint site URL and select “Trello” list from “List Name” dropdown.
  • It will populate columns from “Trello” list. Now we have to bind details which we want to populate from Trello board into the SharePoint List.
  • Select values as shown in screenshot below:6
  • And we are done! Click on “Create Flow” and once it is completed, it will display message on top “Your flow was created. To exit, click “Done”. Then Click on Done.
  • You can manage newly created flows by clicking on “My Flows” from Top Navigation.
  • Now enter new cards in “MS Flow Test Board” with Name and Description and you will be able to see those entries added in “Trello” SharePoint list.8

    Happy SharePointing!!

SharePoint Debugging : Determine which worker process to attach while debugging

Most of the times, during SharePoint debugging,we see that while trying to attach to process “w3wp”, many process with same name are listed.

How to determine which process we need to attach to? As the dialog box does not contain Application Pool details. Follow the steps given below to easily identify the correct worker process.

  1. Open the Command Prompt with Administrative Privilege
  2. Change the directory to c:\Windows\System\Inetsrv
  3. run “appcmd list wp“. It would list all the worker processed with ID and application pool information:

apppool

4. Find out process ID associated to the web application pool you want to debug.

5. Go back to Visual Studio “Attach to Process” dialog box and associate to correct process with ID we got in Step # 4.

Happy Debugging!!!!

gulp-spsave : Save files to SharePoint using Gulp

Upload files to SharePoint using gulp-spsave

Gulp

automate-tasks-gulpjs

For those who are new to Gulp, Gulp is node based task runner which prefers code over configuration. Gulp has watcher inbuilt. Hence it can automatically watch for any changes in file.

Upload Files to SharePoint

Two impressive gulp plugins are available would facilitate uploading of files to SharePoint. We will talk about spsave in this post.

 

Gulp-SPSave

Spsave is simple yet powerful plugin developed by s-kainet to upload files directly to SharePoint.  Below is a simple implementation of the same:

gulp.task(“copyToSharePoint”, [“buildJS”], function(){

return gulp.src(“./build/*.js”)

.pipe(spsave({

username: settings.username,

password: settings.password,

siteUrl: settings.siteUrl,

folder: “YourAppAssets/js”

}));

});

 

Where “settings” is the settings file where you can store sensitive information.

Vardhaman Deshpande has integrated this plugin with gulp watcher functions along with other gulp functions to achieve following:

  • Concatenate all js files into single js file
  • Minify js file
  • Rename file to min.js
  • Upload files to SharePoint
  • Watch for any changes in file and upload to SharePoint

 

Following are the plugins that are used in demo:

  • gulp-concat : Used to bundle js files.
  • gulp-uglify : Used to minify the js files
  • gulp-rename : Used to rename the minified file to .min.js
  • gulp-spsave : Used to upload files to SharePoint

 

 

Videos in Sharepoint

​Playing videos in sharepoint is bit tricky. Specially when you want to play videos with certain start and stop conditions as well as on all devices and on all browsers!

Problem:

Requirement was as follows:

Dynamic poster image should be displayed and on clicking on image, dynamic video should play and after playback completes, again poster image should be displayed.

Should Work on: IE8,IE9+,Chrome,FireFox,Safari(For Mac & Windows)

Devices: Both PC and Mobile devices

Attached is the excel which contains various approach taken and problems with implmenting approach on various devices.

VideoTags

Resolution:

YouTube videos were embedded into code with help of YouTubePlayer API.

https://developers.google.com/youtube/iframe_api_reference​​

Following is sample code which can be tested in CEWP in sharepoint :

<script type=”text/javascript”>

function onYouTubePlayerAPIReady() {

var player = new YT.Player(‘divStartPlayer’, {

height: ‘555’,

width: ‘1000px’,

videoId: ‘hsfUNRRu0VY’,

events: {

‘onReady’: onPlayerReady,

‘onStateChange’: onPlayerStateChange

}

});

}

function onPlayerReady(event) {

if (!(navigator.userAgent.indexOf(‘iPad;’) > 0))

{

event.target.playVideo();

}

}

//Function to be called after video playback is completed

function onPlayerStateChange(event) {

if(event.data === 0) {

ShowHideVideo();

}

}

</script>

<div id=”divStartPlayer” ></div>

Notes:

1) videoId​ is the ID of YouTube video

For Eg. YouTube video link looks like this

www.youtube.com/watch?v=hsfUNRRu0VY

here, hsfUNRRu0VY is the ID of video

2) Note the code navigator.userAgent.indexOf(‘iPad;’) > 0 in onPlayerReady

function. Reason for placing such condition is that iOS does not support auto

playback of videos. (Check below link for reference)

iOS Auto-Playback disabled

So, if code contains method for playing videos, video will not load at all in iOS devices.​

 

 

sharepoint column default value settings not applied via content type

Problem:

Created Document library and associated custom content type with a site column containing default value. Say a numeric field with default value 1.

But when i upload document and select my custom content type, default value does not appear and is always blank.

Reason and solution:

Thanks to SWEE CHING’s article, that i found the solution. Reason was that my custom content type was not set as default content type. If you want your default values to appead pre-selected, you have to set your custom content type as default.

Hope it will help someone!

Fix Publishing Pages Page Layout URL error – Value does not fall within the expected range

While accessing publishing pages, you may encounter error –  “Value does
not fall within the expected range” . It happens due to one of the following reasons:
  • If the publishing layout URL of a publishing page contains an incorrect top level site URL.
  • If there is a problem with the Page Layout, or if the Page Layout is corrupted.
  • If a content database was moved or a content deployment job was run.
 
If you encounter this issue due to reason – 1 i.e. “If the publishing layout URL of a publishing page contains an incorrect top level site URL.”, you can fix it by executing following script.
 
It will fetch URL from Page Layout and verify if it is same as top level site URL. If not, it will change it to top level site URL and approve the page.
 
function AutoApprovePage($page)
{
    if($page.ListItem.ListItems.List.EnableModeration)
    {
        #Check to ensure page requires approval, and if so, approve it
        if ($page.ListItem[“Approval Status”] -eq 0)
        {
             write-host ” | Already approved:”, $page.Title -nonewline
        }
        else
        {
            $page.ListItem.File.Approve(“Page approved automatically by PowerShell script”)
             write-host ” | Approving:”, $page.Title -nonewline
        }
    }
    else
    {
         write-host ” | No approval required for: “, $page.Title
    }
}
 
CLEAR
$site = Get-SPSite -Identity “http://br203:50000&#8221;
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
Write-host “Processing SPWeb: “$pubWeb.Url
Write-host “Title: “$pubWeb.Title
       
$pagesList = $pubWeb.PagesList
$pageCount = 0
$badUrlCount = 0
$fixUrls = $true
foreach($page in $pagesList.Items)
{
    $curPubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($page)
    $pageLayout = $curPubPage.ListItem.File.Properties[“PublishingPageLayout”]
    $url = $pageLayout.SubString(0, $pageLayout.IndexOf(‘,’))
 
    $pageCount += 1
    if(!$url.StartsWith($site.RootWeb.Url,[System.StringComparison]::OrdinalIgnoreCase))
    {
        Write-Host ” |-Page:”$page.Title
        Write-Host ”   |-Layout:”$url -nonewline
        if($fixUrls)
        {
            #Construct the path to page. First, get the last index of / to getthe page name
            $pos = $url.LastIndexOf(‘/’)
            if($pos -ne -1)
            {
                $pubSPFile = $curPubPage.ListItem.File
                $rootWebUrl = $site.RootWeb.Url
                $pageName = $url.SubString($pos + 1)
                $newPageLayout = $rootWebUrl + “/_catalogs/masterpage/” + $pageName
                $pageLayoutFile = $site.RootWeb.GetFile($newPageLayout)
                if($pageLayoutFile.Exists)
                {
                    $checkedOutToUser =  $pubSPFile.CheckedOutByUser
                    if(($pubSPFile.CheckOutStatus -ne “None”) -and $undoCheckOut)
                    {
                        Write-host ”   |-File is Checked Out to: “$checkedOutToUser.Name”, but will be overridden” -foregroundcolor blue -nonewline
                        $pubSPFile.UndoCheckOut()
                    }
                    if($pubSPFile.CheckOutStatus -eq “None”)
                    {
                        $pubSPFile.CheckOut()
                        # Save the page layout as “url, pagename” (with a single space after url, this is important)
                        $propVal = $newPageLayout + “, ” + $pageName
                        $pubSPFile.Properties[“PublishingPageLayout”] = $propVal
                        $pubSPFile.Update()
                        $pubSPFile.CheckIn(“Fixed page layout url via auto-script.”,[Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
                        AutoApprovePage($curPubPage)
                        $fixedUrlCount += 1
 
                        Write-Host ”   |-SetUrl:”$newPageLayout -nonewline
                        Write-Host ” (Fixed)” -foregroundcolor Green -nonewline
                    }
                    else
                    {
                        Write-host ”   |-Not fixed. File is Checked Out to: “$checkedOutToUser.Name $checkedOutToUser.Email -foregroundcolor blue -nonewline
                    }
                }
                else
                {
                    Write-Host ”   |-Not fixed. The page layout $pageName does not exist in the root web master page gallery.” -foregroundcolor blue -nonewline
                }
            }
        }
    }
}
 

Sharepoint Search Error/Search Service stuck at starting/Start or Stop a service using powershell

If ever you encounter a problem where search service is stuck at starting,or you recieve following message in event viewer related to search service, try steps given below:

The Execute method of job definition Microsoft.SharePoint.Search.Administration.SPSearchJobDefinition (ID ) threw an exception. More information is included below.
Retrieving the COM class factory for component with CLSID {} failed due to the following error: .
Event ID: 6398

First of all check if search service is started in services.msc

If still problem persists,
1) open windows powershell
2) Get Service InstanceID of search service application by entering following command:
Get-SPServiceInstance

​It will display all services with its ID

searchservice (1)

3) Copy ID of search service  and execute following command

Stop-SPServiceInstance -Identity <ID of search service>

 

4)Start search service using following command

Start-SPServiceInstance -Identity <ID of search service>