Use Flows to Post Messages to Microsoft Teams

This new extension provides support for:

Post Message to MS Teams
Create Teams Channel
Invite User to Teams Channel
Kick User from Teams Channel
Delete Teams Channel

Post Message to MS Teams

The Message data structure is discussed here: https://docs.microsoft.com/en-us/graph/api/resources/chatmessage?view=graph-rest-1.0

Input Properties

subject
body


Output Properties
messageId
errorText

The only Teams inputs we will support in this first version are Subject and Body. They should be string inputs on the action.
Verify that rich text entered into a Flow Text Template can be passed by reference into the Body of this action and the formatting is retained in the posting on Teams.

If an error is returned extract the most readable part of the error text and return it in the ErrorText output attribute

Create Teams Channel

Input Properties
displayName
description
membershipType

Output Properties
same as for ‘Post Message’, above, except call it ‘ChannelId’

Invite User to Teams Channel

This Teams API takes a huge User object, but we’ll just have our action take an id String initially. Convert it to the expected User structure

Input Properties
userid
channelId

Output Properties
errorText

Kick User from Teams Channel

Input Properties
channelId
userId

Output Properties
errorText

Delete Teams Channel

Input Properties
channelId

Output Properties
errorText

Authentication

setting up authentication to make calls to the Microsoft Graph API is challenging but anyone who administers Teams will probably be familiar with the process. Currently, the only tokens we’ve tested this with are developer tokens that last for 1 hour and have to be refreshed, and the tokens are generated through a complex process involving HTTP and a rig like Postman.

Here’s the Postman configuration that I use to generate valid auth tokens:

All access to Teams starts with an Azure App. This produces the clientID and TenantID

You combine that app id info with a client secret to create an environment that you use to get a temporary access token:

You can generate Client Secrets from the Azure App management UI:

This gives you the access token. Teams actions also usually require IDs for the Team and Channel:

You can generally extract these values from the URLs found in Teams:

https://teams.microsoft.com/l/channel/19%3ac44259973e3a444ebcb82aeb0d5b272f%40thread.tacv2/General?groupId=cc3f17a9-b923-468b-96bf-4fb29057976a&tenantId=168867c6-0022-4fde-92ab-591b3813d528

However, you have to watch out for the encoding. In the example above, the channelID that Flow would expect is

19:c44259973e3a444ebcb82aeb0d5b272f@thread.tacv2

and the teamsID is referred to here as the groupID and Flow would expect;

cc3f17a9-b923-468b-96bf-4fb29057976a

There is certainly a better way to extract these ID’s! This is an area where I’m sadly ignorant, and Teams experts are encouraged to comment on this post with improvements to these docs.

Install

Prerequisites

Step 1) Install Required Support Packages

This extension requires the following extensions, which should be installed first, in order. If you already have these extensions then you may not need to install them. However, you may need to upgrade them.
Install: Flow Actions Base Pack minimum version 2.16
Install: Flow Screen Components Base Pack minimum version 2.2
Install: Datatable minimum version 3.0.10

Step 2) Install MSTeamsActions

Version 1.0.0 Unmanaged 4/1

View Source

Source

March Community Video ‘Flowcast’

Much like last month’s ‘Flowcast’ – I highlight a bunch of components, articles, and actions featured here on UnofficialSF – check it out in the link below!

The description in the video has links to each of the articles mentioned – enjoy!

From Sharad: Style Your Flow with Headers, Banners, Rules, Formatting and More

In need of making your flows looks more like a Salesforce Standard Page Layout? OR Simply want to display customizable headers with icons, text, links, etc. in communities, home/record pages? This Flow extension allows you to display customizable headers in flow screens but also works anywhere on Salesforce platform.

What Features does this component have?

  1. Full control over text-color, font, background-color, section border, text alignment, etc.
  2. Ability to display text (with/without) icon
  3. Ability to use Lightning-icons or custom image stored as a static resource
  4. Display hyperlink
  5. Use as a Line/Page Break
  6. Ability to use the same component multiple times in a screen to ensure consistency or to get variety
  7. and more…..

Where can I use it?
The Customizable Header/Banner works with-

  1. App Page
  2. Home Page
  3. Record Page
  4. Flows
  5. Communities

Usage Examples

1) Insert Section headers

Scenario- Users have always wanted their flow screens to resemble like Standard Salesforce page layouts.

Use Case: Lightning Scheduler has a default review screen with countless fields. Create a custom version with headers. Optionally, add images (either lightning icons or static resources).

2) Insert horizontal rule/line

3) Formatted Banners

In Community

In Record Page

4) Reuse the component with different styling

Considerations

  1. To use image from static resource
    1. After package installation, check to see if there exists a static resource by the name of ‘customHeaderImages’. If yes, Skip the next step.
    2. Create a static resource by the name- customHeaderImages, set Cache Control to ‘Public’
    3. Create a zip file with the name as ‘customHeaderImages’ containing your desired images. Upload the zip file to above Static Resource
    4. When setting up the LWC, enter image name and check ‘is Image a Static Resource?’ to true. Additionally, select either of the options to display image and text
    5. NOTE: Make sure that you are not compressing a folder when zipping the images. Only select the image(s) you want to use and NOT the folder in which that image is.
  2. In terms of preference (if more than one option is selected)- ‘Is header text only?’ > ‘Header has text (left aligned) and image (right aligned)’ > ‘Header has image and text (with image on left of text)’
  3. Image name accepts static resource as well as Lightning icon. For more information on lightning icons, visit- https://www.lightningdesignsystem.com/icons
  4. Important When using within a Lightning Flow, remember to create a variable for each value you would like to pass
  5. Important When using within a Lightning Flow, remember to re-enter values for boolean fields which are supposed to be true, for example- ‘Is header text only?’ will by default be populated as True- ‘{!$GlobalConstant.True}’- clear the field and re-enter ‘{!$GlobalConstant.True}’

Input VariableDescriptionDefaultNotes
Display for Record Id?Only appears on record page. To show the banner for a particular record, update the field value with recordId (from URL). Else, leave it blank to display the banner for all records.
Display as horizontal line?Check to use as a page break or underline a headerFALSEIf selected it gets the highest priority and the header is displayed as a horizontal line. Once selected, control the display using Banner Height and Banner Background-color fields
Is header text only?Use when the text is not accompanied by an image- lightning icon/static resourceTRUE
Banner TextText to display inside of the bannerBanner Text Goes Here
Banner Text AlignmentUse to align the banner text. Valid inputs: left, center, rightcenter
Display text as hyperlink?Check when the text is a link to a webpage,article,etc.FALSEOnce selected, be sure to fill out the URL to redirect field with a valid URL
URL to redirectEnter a valid url for the user to be redirected to when the text is displayed as a hyperlink
Remove text-decoration for the link?Check when displaying the text as URL and you want to remove the text-decoration, ex-underline under the hyperlink.FALSE
Open link in new window?Check when displaying the text as URL and you want the link to open in a new windowFALSE
Order NumberWhen using this component more than once on the same screen, be sure to provide a unique order number to each of the component to ensure that styling(CSS) from one component does not interfere with that of the other. Example, when using the component twice on a screen, give one component an order number of 1 and the other as 2.
Image NameWhen displaying image along with text, use this field to provide the image name. To use a lightning icon, enter name as ‘utility:add’ or ‘custom:custom1’. To use image from static resource, follow step#1 aobe and create a static resource. Once created, simply provide the image name.utility:add
Is image a Lightning Icon?Check when using a lightning icon.FALSEGets priority over- ‘Is image a static resource’ if both are selected
Lightning Icon SizeValid inputs: xx-small, x-small, small, medium, or large.medium
Icon MarginProvide margin to include space between icon and text-useful when the icon is left aligned and text follows the icon0px 7px 0px 0px
Is image a static resource?FALSE
Banner HeightUse to define banner height in %. Also controls the banner thickness when using as a page break10
Banner Background ColorTo define banner background color, use any- #hexcode or RGB(0, 0, 0) or color namergb(243, 242, 242)
Banner Text Font SizeValid inputs: xx-small, x-small, small, medium, or large.
Banner BorderWhen wanting to have the banner border radius, include width, style (required) and color, example- 0px 0px 5px 0px dotted red;

Static Resource Setup-

Configuring the Component In a Flow

Problem With Literal Values

Currently there are some problems providing literal values, so at this time you should only pass in variables. This is being investigated. Example- create a text variable ‘bnrBrdrRds’ for Banner Border Radius with value equals to 12px and use {!bnrBrdrRds} instead of simply typing in 12px in the input field- see below image.

Note#2: Remember to re-enter values for boolean fields which are supposed to be true, for example- ‘Is header text only?’ will by default be populated as True- ‘{!$GlobalConstant.True}’- clear the field and re-enter ‘{!$GlobalConstant.True}’

When using within a community, record/home page-

Any limitations that I should be aware of?

  1. At present, header takes up the space of a single column in case of a 2-column flow layout.

Install

Link to download the package

View Source

Source

From Josh Dayment: Improved File Upload in Flow Screens

Josh writes: One of the common things I hear from users when uploading files in a Salesforce Flow is that they do not know if the file uploaded. This improved File Upload component adds this capability to the standard File Upload. Add this to any screen flow you wish to enable for upload. Once the user uploads files the component:

  1. displays the list of uploaded files, providing visual confirmation
  2. outputs a collection of the newly created contentdocumentId’s for use downstream in your flow.

How it Works

The available inputs are identical to the out-of-the-box file upload:

Property NameDatatype
iconvariable of icon type i.e. doctyp:attachment full list found here
labelLabel for your file upload button
recordIdThis is the record to associate your files with

The newly available contentDocumentIds output can be accessed via manual assignment or via automatic outputs:

Install

Version 1.0

*to install in a Sandbox replace login with test in the url

View Source

Flow Datetime Methods

Flow Datetime Methods

Created by Carl Vescovi


This Post was most recently updated on: 3/27/21
Current Version: 1.0


At the moment Datetime and Business Hours are not particularly well supported in Salesforce Flows. The intent of this code is to be a gap filler until such time as Salesforce delivers more functionality. The way this code works is simple – Salesforce provides much more support in Apex for Datetime manipulation and Business Hours calcs, so the class included here simply serves to provide access to a subset of those Apex Datetime, Date and Business Hour class methods. 48 in total so there is something there for everyone. While some of these functions are probably possible using formulas, in a lot of cases here you can manipulate the result into different timezones and formats – not something I’d personally want to be doing with formulas if there is a ready built capability to be found on the platform.


Datetime support

The Datetime capabilities available to Salesforce Developers can be found here.

The following subset of capabilities or ‘methods’ provided by Salesforce are enabled in Flow through this simple class. To call Datetime specific methods prefix the method with ‘Datetime.‘. For example, to use the Datetime addDays method use the methodname attribute ‘Datetime.addDays’.

  • addDays
  • addHours
  • addMinutes
  • addMonths
  • addSeconds
  • addYears
  • day
  • dayGmt
  • format
  • formatGmt
  • formatLong
  • getTime
  • hour
  • hourGmt
  • millisecond
  • millisecondGmt
  • minute
  • minuteGmt
  • month
  • monthGmt
  • now (exists in Flow however I included this to enable formatting and timezone controls)
  • second
  • secondGmt
  • time
  • timeGmt
  • year
  • yearGmt

Business Hour support

In addition it made sense to extend this class to also provide five methods for Business Hours calculations.

The Business Hours capabilities enabled are described in more detail here.

To access these methods from the action, prefix the method you want to use with ‘BusinessHours.‘. For example, to use the diff method you’d populate the action attribute ‘methodName’ with ‘BusinessHours.diff’.

  • add (add business hours time to a starting datetime)
  • addGmt (add business hours time to a starting datetime and return in Gmt)
  • diff (return difference in milliseconds between two datetimes, only considering business hours)
  • isWithin (confirm if a datetime is within business hours)
  • nextStartDate (confirm next closest date that is within business hours)

Date support

Was on a role by this stage so figured best to expose the Date Class methods as well.

More information on Date Class methods can be found here.

To access the following Date Class methods, prefix the method you want to use with ‘Date.‘. For example, to use the dayOfWeek method you’d populate the action attribute ‘methodName’ with ‘Date.dayOfWeek’.

  • addDays
  • addMonths
  • addYears
  • day
  • dayOfYear
  • daysBetween
  • daysInMonth
  • format
  • isLeapYear
  • isSameDay
  • month
  • monthsBetween
  • today
  • toStartOfMonth
  • toStartOfWeek
  • year

Using the classes from within Flow

Once installed just reference the DatetimeUtility or DateUtility class from within Flow Builder Action to access Datetime and BusinessHours methods, or DateUtility class from a Flow Action to access the Date methods.

Once selected, you’ll want to configure some attributes. There are 3 to 4 attributes to populate depending on which method you wish to call. If its not intuitive enough let me know and I’ll expand the documentation.

Utility Method attributes

The following attributes can be configured once you’ve created the action using either of the DatetimeUtility or DateUtility Classes

  • methodName. This is mandatory and if not valid the logic will error out with an invalid method name error at runtime. The method names used in the class are exactly as they’re documented in the formal Salesforce documentation, just without the brackets. So where Salesforce calls a method ‘addDays()’ you’d just use ‘addDays’.
  • dateTimeString. This is mandatory and is the Flow datetime variable you want to manipulate. Typically from a datetime input field for example. The format of a Flow datetime string is like this ‘1/1/2021, 3:47 pm’ or the pattern ‘dd/mm/yyyy, hh:mm:ss a’.
  • increment. This is populated with a number when using the addSeconds, addDays etc. Any method where you’re needing to pass in a numerical value.
  • returnFormat. This is optional on all method calls, allowing you to manipulate the format of the returned result. The expectation is that you’re passing in a string describing a java simple date format pattern. See more on this here.
  • timeZone. This is optional on all methods and assuming you provide a valid timezone code you can have the resulting datetime value returned to you in the timezone provided.
  • secondDateString. This is only used when performing a BusinessHours.diff calculation. The method will thrown a runtime error if this second datetime is not provided.

Response attributes

The Utility returns a response that has a number of attributes you can use as you wish

  • errorOccured. This is a boolean that if true means something went wrong during processing.
  • errorMessage. If errorOccured is true, then there is likely a message provided in this attribute to describe what it was that went wrong.
  • result. This is a string containing the result of the method call. Its worth noting that to keep this consistent ALL results are in string format, including what would normally be expected as an integer or long datatype i.e. the result from ‘day’ or ‘time’ method calls. Sorry about that but I figured trying to accommodate different data types in the result might confuse more than it’d help. Can extend the result class easily enough if you’d prefer more result attributes.

Installation

Production or Developer Version 1.0

Sandbox Version 1.0


Release Notes

3/22/21 – Carl Vescovi – v1.0

Initial Release


Previous Versions


View Source

Source Code

Launch Flows from Salesforce Labs Enhanced Lightning Grid

Praxis Solutions has created a great component to work with Salesforce Lab’s Enhanced Lightning Grid. It can be used to launch flows in a pop-up modal from a row or list button. Visit the unofficialsf.com Applications & Utilities page for more information.

Copy to Clipboard Button

Copy to Clipboard Button

Created by Eric Smith


This Post was most recently updated on: 3/26/21
Current Version: 1.0


See the source image

This Flow Screen Component lets you add a button to your flow screens to copy any provided content into the system clipboard. It provides an easy way to allow a user to copy and then paste the provided data elsewhere on their computer.

Usage

To use this component, add it to a Flow Screen and provide the content you want to make available to be copied to the clipboard.

In this example I’ve created a Flow that shows the contents of 4 different fields from a Contact record. Once activated, I can place it on the Contact record page.

In this example, I’m adding some text to the button and I’m clearing the clipboard display once it has been selected.


Attributes

AttributeTypeNotes
INPUT
Clipboard LabelTextLabel to appear above the Clipboard contents box (Optional)
Button LabelTextLabel to use on the button (Optional)
Clipboard ContentTextSet this to the value to pass into the Clipboard
Content Size (In 12ths)IntegerSet the size of the contents box in 12ths of the total container width (Optional)
Hide Clipboard after Selection?BooleanSet to True to remove the clipboard contents display from the screen once the button is clicked

Installation

Step 1

This component requires that you first install the Flow Base Packs

Step 2

Production or Developer Version 1.0

Sandbox Version 1.0


Release Notes

Note:

You can check the current version of your component by looking at the bottom of the Custom Property Editor.

3/26/21 – Eric Smith – v1.0

Initial Release


Previous Versions


View Source

Source Code

Mass Update Records from a Related List

Melody from Salesforce Flowsome has done it again with a fantastic pair of posts that cover a few different ways to select and mass update records from a list view. These well written articles are easy to follow and present step-by-step how you can implement this functionality using Flow.

Use Case: Mass Update Records From Related List #1 (ids Variable) (salesforce-flowsome.com)

Use Case: Mass Update Records From Related List #2 (ids Variable) (salesforce-flowsome.com)

Flow Carousel

The Flow Carousel allows you display a set of slides in a continuously running carousel within a screen flow it’s useful if you want to put a flow on a lighting record page or run something cast to a screen at an event and allow a remote user to update specific information. There are 4 text collection properties that will build the slides in your carousel. You are limited to max 6 slides (this is a lightning design limitation).

Input

The component only has a handful of properties

  1. Image URL’s: This is a text collection holding the image urls for your slides.
  2. Headers: This is text collection containing the Headers for each slide.
  3. Descriptions: This a text collection of short paragraphs/descriptions for each slide.
  4. Alternate Text: This a text collection the alternate text behind each image this also needs to be unique for each slide as the component uses this to differentiate each slide”
  5. Slide Style: Use this string property to control the slide styling i.e. slds-text-align_center slds-size_x-large this uses standard Lightning Design System attributes. Without styling the default will be aligned left and it will scale all slides to the largest image you have so keep in mind if you use this or not.
  6. Carousel Title: This string property adds a title to your component.

Install

Version 1.0.0 unlocked 3/25

View Source

From Jeremiah Dohn: Generate Collection Report now displays parent relationship fields and field labels

The Generate Collection Report component is very useful when needing to show a list of records or for an input into outbound emails (using Send Better Email). It has now been enhanced to:

1) display field labels instead of field names in column headers and

2) allow the display of fields from related parent records.

This will work for standard or custom objects and fields and supports many relationships.

Below is a sample output leveraging a multilevel relationship:

How it Works

When specifying your display fields in the ‘shownFields’ input, use dot notation to specify related fields: