August 12, 2020

[Resolved]: Getting null values from Multiline Text field with Append Changes Option in Power Automate

Problem statement:

We had a requirement where we need to get values of multiline text field from SharePoint list and use it in one of the action in Power Automate. The real twister was when we found that multiline text column was setup with Append changes to existing text option. The problem was we were getting blank/null response when we try to access that field directly in Email body action using Power Automate.


Analysis & Findings:

We dig out the issue and found that when we set multiline text field with append changes option, and add any value in that field, it stores the value as separate version of an item and not storing directly to that field.

Solution:

We need to get those values from the version history of an item but there is no direct way for it. So, we need to follow below steps to get values from multiline text field in power automate.

First, we need to initialize below variables that will be used to get version history of an item in Power Automate.

 

  • Add an action name “Initialize Variables”.

  • It will ask following information.
    • Name
    • Type
    • Value

  • Now, let’s create first variable name “AppendComment”.
    • Name AppendComment
    • Type String
    • Value <div class="ReactFieldEditor-AppendedData"><div>

  • In a similar way, we need to create a variable - “ColumnName”.
    • Name ColumnName
    • Type String
    • Value Column name from the list. Use the internal name. [Multiline Text Column]

  • And third variable will be “ListName”.
    • Name ListName
    • Type String
    • Value Your list display name. [ SharePoint Custom List Name]

  • Now, add an action for “Send an HTTP request to SharePoint”.

  • Add the following information in that action:
    • SiteAddress - URL of your SharePoint Site
    • Method - GET
    • Uri  - /_api/web/lists/GetByTitle('@{variables('ListName')}')/Items(@{triggerBody()?['ID']})/Versions
    • Headers
      • Accept (should be added as key)
      • application/json; odata=nometadata (should be added as value)

  • Now add an action called - “Apply to each”.

  • And set below value in that action.
    • body('Send_an_HTTP_request_to_SharePoint' )['value']

  • Now add "compose" action inside Apply to each action.

  • Add below value in Inputs textbox.
    • formatdatetime(items('Apply_to_each')['Modified'],'MM/dd/yyyy hh:mm tt')

  • Then we need to add Condition action.

  • Add below expression in First section:
    • items('Apply_to_each')[variables('ColumnName')]


  • Then select "is not equal to" in second section.

  • And then in third section, add null as value in expression as shown below. 

  • In YES side condition, add an action “Append to string variable”.

  • Please set below expression and click ok
    • Name - select AppendComment
    • Value - In expression, add below value:
      • concat('<div>',items('Apply_to_each')['Editor']['LookupValue'],' (<span>',outputs('Compose'),'</span>)',': ',items('Apply_to_each')[variables('ColumnName')],'</div>')

  • Finally, Value is set in AppendComment variable. And we can use "AppendComment" variable in Send an email action.

  • By following all above steps, finally we got correct output:


If you have any questions you can reach out our SharePoint Consulting team here.

August 6, 2020

Introduction to SharePoint Spaces

Overview:
Microsoft recently launched SharePoint Spaces and it is in preview at this moment. During this article we will cover the following things.
  • What is SharePoint Spaces?
  • Characteristics of SharePoint Spaces
  • Real-Life Use cases for SharePoint Spaces

What is SharePoint Space?
  • SharePoint spaces is a web-based, immersive platform, which allows us to create and share, secure, and extensible mixed reality experiences.
  • SharePoint Space adds a new dimension to our intranet by using 2D and 3D web parts to create a mixed-reality vision.
  • Building space is a lot like building a modern site -- that is, we create the space by choosing options such as structure, background, and theme. And then add web parts using 3D objects, 360° images & videos, 2D images, text, and more.

Characteristics of SharePoint Spaces:
  • Cross-platform - Supports a wide range of web browsers and mixed reality devices.
  • Made for creators - Commingle 2D and 3D content to create custom experience that tells our stories in stunning 360° view.
  • Secure and compliant - Secure on Microsoft 365 ecosystem.
  • Integrated and extensible - Since this is a platform, Microsoft will grow over time to include 3rd party web parts and extensions using the SharePoint Framework.

Real-Life Use Cases where SharePoint Spaces can be utilized:
We all know SharePoint Spaces provide Mixed Reality experience to our SharePoint intranet portal. It can be used in the following areas:
  • Virtual Tours - Tour of a New Building, Demo of  New Product Launch
  • Training - Training with 3D Models and 360° videos. Virtual Simulation is more affordable and can be repeated multiple times so that your employees have the practice they need to accomplish their work.
  • Learning beyond the classroom - Teachers can import visual lessons, visualizations, and videos (2D, 3D, and 360°) that support their lessons and create a powerfully engaging learning environment.
  • Onboarding Activities - SharePoint Spaces help new employees with their organizations and teammates more quickly by exploring the company and their colleagues via a virtual organizational chart. Also, 3-D office maps can help newcomers to get used with the new environment faster.

If you have any questions you can reach out our SharePoint Consulting team here.

May 15, 2020

How to set Item level permission in SharePoint List/Library using Power Automate

Introduction:

In this blog, we can learn how we can set item level permission on a List Item or a Document when new item or document is created or modified in SharePoint List/Library. Using Power Automate (MS Flow), we can achieve this by breaking inheritance and assign specific permission to SharePoint User/Group.

Here are detailed steps to be followed in your SharePoint Online tenant to meet the requirement.

Step 1:  Create new flow from blank template. Add a trigger “When a file is created or modified in a folder” and entered your Site address URL (http://yourtenant.sharepoint.com) and List/library URL(/SitePages) for which you need to set unique permission.

 

Step 2: Add an action “Get file metadata” and configure with the values as shown in below screenshot.

 

Step 3: Add next action “Get file properties” and configure with the values as shown in below screenshot.


Step 4: Add an action “Initialize Variable”, Name it as “AuthorPrincipal” as shown in the below screenshot. This will be used to store Author User Principal id.

 

Step 5: Add one more action called “Initialize Variable”, rename it as  “GroupID” as shown in the below screenshot. This will be used to store Principal Id of SharePoint Group.

 

Step 6: Then we need to add an action called “Send an HTTP request to SharePoint” to break permission on an item and need to pass parameters as shown in the below screenshot.

 

Step 7: Now, to assign specific permission to a user on that item, first we need to get the Principal Id of the user (here, Modified By user). For that, add another action “Send an HTTP request to SharePoint” and configure all fields as shown in the below screenshot.

 

Step 8: Now, store that Principal Id  of that user in a variable. To do that, add action “Set Variable” and set the value with => Body(‘Send_an_HTTP_request_to_Sharepoint_2’)[‘d’][‘id]

 

Step 9: Now to assign permission to item/document, add an action “Send an HTTP request to SharePoint” and configure fields as shown in the below screenshot. Here, we are assigning Contribute permission to Last Modified By User.

 

To assign permission to a SharePoint group, you can follow steps 10, 11 & 12 instead of 7,8 & 9 and setup flow accordingly.

Step 10: First, to get the Principal Id of SharePoint group, add an action “Send an HTTP Request to SharePoint” with values as shown below screenshot.
  • Set Uri as “/_api/Web/SiteGroups/GetByName(‘Your-group-name’)  
Note: “Content-Approval” is custom SharePoint group.

 

Step 11: Now, to store Principal Id in a variable, add an action “Set Variable” and rename it as “Set-GroupID” and configure with value => Body(‘Send_an_HTTP_request_to_Sharepoint_5’)[‘d’][‘id’]

 

Step 12: Now, to assign permission to that SharePoint group, we need to add an action “Send an http request to SharePoint”, and configure its value as shown in the below screenshot.

 

Important Notes:
1. Below is table listing different Role Definition Name and Id that can be used in MS Flow as per requirement.

Role Definition Name
Role Definition Id
Full Control
1073741829
Design
1073741828
Edit
1073741830
Contribute
1073741827
Read
1073741826
View Only
1073741924

2. Also, we can reset the permission and assign Parent level permission on the item by adding action "Send an HTTP request to SharePoint" with values as shown in below screenshot.

 

 If you have any questions you can reach out our SharePoint Consulting team here.