Flow, PowerApps, PowerObjects, PowerPack

Extending PowerHashTag solution with Flow for PowerApps

There are multiple ways to specify an entity type in PowerApps. Most of the time you would use something like an optionset field or reference to a list type via lookup.

However, in those cases you need help from someone who’s got the power to customise the system for you or has the permissions to modify the reference data.

Using hashtags makes it easier for end users to specify their own types in PowerApps.

The PowerHashTags solution from PowerObjects is a perfect way to give users more power to categorise records and search for a particular record based on the tags defined.

There is a very easy to follow user guide, which I used to set up the solution.

My favourite part is picking up colours for different tags…

1

… so they look pretty on a form.

2 - Copy

To look up all records associated with the tag just click on it to open the form and explore records under the Tagged area.

3

As you can see, there are different types of records, not only accounts but also contacts. In my case I tagged people skills for Dynamics 365 and Dynamics 365 companies as well.

At the back end the PowerHashTag solution uses out of the box Connections functionality to support tagging. Let’s have a look in the Advanced Find.

4

The result list of records for my query contains all connections where the Type(To) equals “PowerHashTag”.

5

The requirement is to retrieve all companies working in the Dynamics 365 space and located in Australia. Currently, there are multiple companies in the system matching the criteria.

I tried the query below:

6

7

Am I happy with the result? Not quite. There is the company, Alphabet, which is US based and doing Dynamics 365. It shouldn’t be in the results. There reason it’s there, I used OR in my query. Let me fix it.

8

9

Well, as you can see, it doesn’t work this way for Connections. At least, not out of the box.

There is a no-coding solution which is also a good opportunity to learn more about Microsoft Flow.

The idea is, on creation of a new tag, concatenate all hashtags into a long string and store it a custom field on the Account entity. Old school workflows won’t allow us to do so. We need to ask developers to build a custom workflow activity for this. Luckily, we have Flow to rescue us.

First, we need a new custom text field on the Account entity, something like this:

10

Second, let’s make sure we have Change Tracking ticked so Connections is enabled for Flow.

11

Nice. Pick up the Flow item from the form menu then Create a flow.

12

I’ve built my flow already. So, let’s just have a look inside. Let’s open the designer.

13 - Copy

14 - Copy

It’s a very minimalistic flow. For best practice one would, probably, contain multiple check for nulls and more logic to handle all sort of exceptions. In the dev world, in my “Hello Flow” world it’s good enough though.

Step 1. Trigger

The flow gets triggered when a new Connection is created for the organisation.

15 - Copy

Step 2. Sooner or later you realise you need a variable to store your concatenated string.

16 - Copy

Step 3. We are interested in the PowerHashTag to Account connections only.

No basic mode, sorry. The condition to filter is: @and(equals(triggerBody()?[‘_record1id_type’], ‘accounts’), equals(triggerBody()?[‘_record2id_type’], ‘poht_hashtags’))

17 - Copy

Step 4. Only if Step 3 is valid, get all PowerHashTag connections for the trigger connection Account. We need them to re-build the Tags string

18 - Copy - Copy

I was stuck here for a while trying to use _record2id_type in the filter. I gave up and included record2objecttypecode eq ‘PowerHashTag’ which is not ideal. But we leave it as is for now.

Step 5. Getting the trigger connection Connected From the account record.

19 - Copy - Copy

Step 6. Stack of actions. Iterating through the list of Connections from Step 4.

20 - Copy - Copy

Step 6.1 Parse JSON to get to the friendly properties format.

21 - Copy - Copy

Step 6.2. Getting the current PowerHashTag

22 - Copy - Copy

Step 6.3. Appending the current PowerHashTag to the Description variable.

23 - Copy - Copy

The concatenation function looks like: concat(body(‘Get_record_3’)?[‘poht_name’],’,’), where ‘Get_record-3’ (#badNamingConvention) is the current PowerHashTag name.

Step 7. Updating the Account record with the Description.

24 - Copy - Copy

25 - Copy - Copy

In PowerApps for the account with the tag added we can see an updated Tags text field. We don’t need to show the field on the form, only while testing the solution.

26 - Copy - Copy

The Advanced Find query for Accounts now retrieves us the information required:

27 - Copy - Copy

28 - Copy - Copy

For the complete solution, consider a couple more flows: on delete of the tag to account association, on delete of a tag, on update of a tag name. They share the same business logic, so we could add reusable code into a “child” flow.

1 thought on “Extending PowerHashTag solution with Flow for PowerApps”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s