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

Content Organizer execution order

Content Organizer is used to organize your content automatically, based on custom-defined rules. However, these rules add new entity to the hierarchy of events that can be executed for the List items, and this execution order is not well documented. It’s important to understand the sequence to process documents accordingly.
For example, when the user uploads his CV to the library you want to add watermark by Workflow, update .docx metadata with event receiver and round document to “unprocessed” folder using content organizer. We have “DropOff Library” with WorkFlow, EventReceiver attached and with Content Rules. The default execution sequence will be the following:
  1. WorkFlow
  2. Event-Receiver
  3. Content Organizer Routing Rules
PS: Take into account that WF/EventReceiver sequence can be changed programmaticaly, using Sequence property of SPList.EventReceivers, but when you reconfigure Workflow it always gets the first order in execution
PPS: Content Organizer Routing Rules impersonates the Application Pool account, thus in might perform actions under “System Account” and your destination folder’s WorkFlow will not start.

Sandbox solution to manage anonymous access on Office 365 / SharePoint 2013.

You can enable anonymous access to office 365 account using following sandbox solution:

http://anonymous365.codeplex.com/

Steps to configure a sharepoint list on my public facing sharepoint site that is accessible for anonymous users:

  • Download the anonymous365 sharepoint solution from http://anonymous365.codeplex.com
  • Go to the “Site Settings” of your public facing site using by example :http://brxyz/_layouts/settings.aspx
  • Go to the “Galleries” section and go to “Solutions“.
  • Click under the “Name” colume and in the ribbon interface under the “Solutions” tab choose “Upload Solution“.
  • Browse to the previously downloaded anonymous365 sharepoint solution : “Wsp365.Anonymous.wsp” and press “OK“.
  • Check the checkbox of the uploaded “Wsp365.Anonymous.wsp” and in the ribbon interface under the “Solutions” tab choose “Activate“.
  • The go to the “All Si​te Content” of your public facing site using by example: http://brxyz/_layouts/viewlsts.aspx
  • Press “Create“
  • Choose the list type you want, enter a name and press “Create“.
  • Then in the ribbon interface under “List Tools” and “List” press the button “Anonymous Access“
  • Choose what acce​ss you want to give anonymous users for this specific list and press “OK”example

Client Object Model Access Large Lists/Overcome ListView Threshold while accessing large list

If you want retrieve large list using Client Object Model. You can use the ListItemCollectionPosition class to implement paging list item retrieval according to the position of items relative to their collection. Use the RowLimit element to specify the number of items to return per page.It is very useful when list view threshhold limit is reached.

static void Main(string[] args)
{
ClientContext clientContext = new ClientContext(“http://testLink”);

List list = clientContext.Web.Lists.GetByTitle(“Tasks”);

ListItemCollectionPosition itemPosition = null;
while (true)
{
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml = @”<View>
<ViewFields>
<FieldRef Name=’Title’/>
</ViewFields>
<RowLimit>1</RowLimit>
</View>”;

ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();

itemPosition = listItems.ListItemCollectionPosition;

foreach (ListItem listItem in listItems)
Console.WriteLine(“Item Title: {0}”, listItem[“Title”]);

if (itemPosition == null)
break;

Console.WriteLine(itemPosition.PagingInfo);
Console.WriteLine();
}

Console.ReadLine();
}​

Shrarepoint 2013 Display Templates

Display Templates
Display Templates control which managed property is shown in the search results and how they appear in the Web Part. Each Display Template has two files: an HTML version of the Display Template that you can edit in your HTML editor, and a .js file that is for SharePoint use and should never be modified.
Control Template provides HTML to structure the overall layout for how you want to present the search results. For example, the Control Template might provide the HTML for a heading, beginning and end of a list. The Control Template is rendered only once in the Web Part.
Item Template provides HTML that determines how each item in the result set is displayed. For example, the Item Display Template might provide the HTML for a list item that contains a picture, three lines of text that are mapped to different managed properties associated with the item. The Item Display Template is rendered one time for each item in the result set. So, if the result set contains ten items, the Item Display Template creates its section of HTML ten times.
For example to customize template for search results web part, you need to change following things:

OOTB search results will be displayed in following format:
1.png
If we want the above data to be displayed in tabular format, few changes needs to be done:
Explore Display Templates
Open the required site in SharePoint designer.
Navigate to the following highlighted path:
2.png

You can see few files with suffix Control_ these are control templates and one marked with Item_ are item templates. The best way to create new display template is copy an existing display template to new one and edit the same. In our example, we will copy Control_SearchResults.html and name it as Control_SearchResults1.html. For item template, we will copy Item_Default.html and name it as Item_Default1.html.
Explore Control Display Template:
Open Item_Default1.html in SharePoint designer and make
Header Properties
This section has Display Template header properties that provide information to SharePoint about Display Template, <title> will be displayed under web part Edit Properties to choose from.
Script Block
This section is used to reference JavaScript and CSS files.
 <script>
        $includeLanguageScript(this.url,”~sitecollection/_catalogs/masterpage/Display Templates/Language Files/{Locale}/CustomStrings.js”);
        $includeScript(this.url,”~sitecollection/style library/slider/js/jquery-1.9.1.min.js”);
        $includeCSS(this.url,”~sitecollection/style library/Slider/css/example.css”);
</script>
Few important points to note here:
·          Any JavaScript Code should be inside  <!–#_ <JavaScript Code> _#–>
·          Use value assigned to variable using _#=   example: <a  href =”_#=LinkURL=#_”>
·          In Control Template  _#=ctx.RenderGroups(ctx) =#_  is used to render  HTML items (actual search results) from Item template.
·          For CSS styling, wrap _#=ctx.RenderGroups(ctx) =#_ with a div and apply css style, this will style all items coming from Item Template. Point to note here is, most outer <div>with ID matching template title will never render in HTML, so be careful not to apply style to outer <div>or it will never reflect.
·          To call a JavaScript function after Display Template is completely rendered use the AddPostRenderCallback function.
               <!–#
           AddPostRenderCallback(ctx, function() {
           //code to execute
            });
             _#–>
There is another way to achieve this by using:
ctx.OnPostRender = function() {
};
Explore Item Display Template
Header Properties
In Item Template Header Property  <mso:ManagedPropertyMapping> is used to map Search Managed Properties, retrieved from search query and map them to fields on Item Display template.
<mso:ManagedPropertyMapping msdt:dt=”string”>'Title':'Title','Path':'Path','Description':'Description','EditorOWSUSER':'EditorOWSUSER&#39 </mso:ManagedPropertyMapping>
In order to use a Search Managed Property, it should be first added under ManagedPropertyMapping header.
mso:ManagedPropertyMapping: This property takes the managed properties that are used by search and maps them to values that can be used by the Display Template. The property is a comma-delimited list of values that uses the following format: ‘property display name'{property name}:’managed property. For example: ‘Picture URL'{PictureURL}:’PublishingImage;PictureURL;PictureThumbnailURL’.
Same as Control Template, Item Template also has Script Block and Outer DIV with matching DIV ID as template name.
DIV Block
Scripting should be put under outer DIV. After you map a property in header, you can get its value in script by using the following code:
_#=ctx.CurrentItem.<Variable>=#_
To display data in tabular format:
<tr bgcolor=”#CCCCCC”>
<th >Title</th><th>Status</th><th>Start Date</th><th>Company</th>
</tr>
<tr >
 <td >
 <div><img src=_#=ctx.CurrentItem.csr_Icon=#_ alt=”Document Icon” >_#=ctx.CurrentItem.Title=#_<br><b>Purpose:</b>_#=ctx.CurrentItem.RefinableString01=#_</div>
 </td>
  <td>
 _#=ctx.CurrentItem.RefinableString02=#_
 </td>
    <td>
            _#=ctx.CurrentItem.RefinableDate00=#_
             </td>
        <td>
            _#=ctx.CurrentItem.RefinableString00=#_
          </td>
         </tr>