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…
… so they look pretty on a form.
To look up all records associated with the tag just click on it to open the form and explore records under the Tagged area.
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.
The result list of records for my query contains all connections where the Type(To) equals “PowerHashTag”.
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:
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.
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:
Second, let’s make sure we have Change Tracking ticked so Connections is enabled for Flow.
Nice. Pick up the Flow item from the form menu then Create a flow.
I’ve built my flow already. So, let’s just have a look inside. Let’s open the designer.
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.
Step 2. Sooner or later you realise you need a variable to store your concatenated string.
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’))
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
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.
Step 6. Stack of actions. Iterating through the list of Connections from Step 4.
Step 6.1 Parse JSON to get to the friendly properties format.
Step 6.2. Getting the current PowerHashTag
Step 6.3. Appending the current PowerHashTag to the Description variable.
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.
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.
The Advanced Find query for Accounts now retrieves us the information required:
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.