Communicating to Field Workers

Communication is everything. This is true also when you build solutions with Power Apps. In many cases Power Apps + Teams is the preferred toolset. On the other hand Power Apps push notifications can be extremely handy in some cases.

In this article I go through one specific but still common scenario. I’ll be using the recently released Microsoft Dataverse for Teams to manage the underlying data and surface it inside the UI of a Power Apps Canvas app.

Imagine we have field workers (mechanics, engineers, electricians, plumbers, etc) working in big construction sites. Each site is divided into several buildings with apartments (and/or offices). One field worker usually works in one room at the time.

During construction there will be huge amount of changes related to rooms. Therefore we have to message about these changes from work management to field workers.

Of course electrician should see easily if there is any new messages related to the kitchen s/he is currently working on.

Let’s start.

Datamodel

We need the follwing tables.

  • Construction site (Project, e.g. construction Site X )
  • Working area (Subproject, e.g. kitchen in apartment 301)
  • Task (Subproject task, e.g. installation of kitchen cabinets)
  • Message (Message). Message is allways related on working area.
  • Read message (Read message). We have to keep track about users who has read the message.
  • Field worker (User). Out of the box user table.

The actual tables inside Dataverse for Teams look like this.

Mobile Power App for Field Workers

First we need App for the field workers. Let’s build it quickly with (canvas) Power Apps. Below you can see the screen from where field worker see all tasks related to some specific room.

Great! Now everyone knows what needs to be done in the site. Field workers mark tasks as done, add comments and so one. They see how much work is left (in the whole site, in some specific floor, in one apartment, etc.)

They can even add extra work with the App during the workday.

But topic of this article was communication..

Messages

Let’s build screen where all messages related to specific room (Subproject) are listed. We need gallery, where messages are filtered by the subproject.

Items: Sort(Filter(Messages, 
                   Subproject.Subproject =  
                   varSelectedSubproject.Subproject), 
            'Created On', Descending)

Next we add envelope icon on the tasks screen for navigating from the tasks screen to the message screen.

Unread Messages

There will be a lot of messages. Users has to see when there is new messages related to subproject s/he is working today.

Lets add red circle on top of the evelope icon. After that we add I add label inside the circle showing count of unread messages.

How we know how many unread messages there are? Easily. Just calculating difference of all messages and read messages.

CountRows(
  Filter(Messages, 
         Subproject.Subproject = varSelectedSubproject.Subproject
  )
) 
- 
CountRows(
  Filter('Read messages', 
         Subproject.Subproject= varSelectedSubproject.Subproject          
         And User.User = varCurrentDataverseUser.User
  )
)

We like to show red circle with label only if there are unread messages. This is done by setting circle (and label) visible property as

lblUnreadMessages.Text <> "0"

Mark Message as Read

To make all this functionality work, we should know who has been read messages. Easiest way is to add “Mark as read” button on each message.

When user clicks this button, we add new row into the Read Messages table.

Patch('Read messages', 
      Defaults('Read messages'), 
      {
        Name:"read by " & User().FullName, 
        Message:ThisItem, 
        User:varCurrentDataverseUser,  
        Subproject:varSelectedSubproject
      }
)

Button should be visible only if message isn’t marked as read allready.

Visible: IsBlank(
           LookUp('Read messages', 
                  Message.'Message (crb24_messageid)' =    
                  ThisItem.'Message (crb24_messageid)',
                  User.User = varCurrentDataverseUser.User
           )
         )

Summary

We are done!

We have one-directional messaging solution for work management to inform field workers about changes.

But be careful when building communication features in your app. There is no sense to build Facebook inside your custom app. In many cases you should use Microsoft Teams for communication part and Power Apps for running the actual process.

Thanks to Dataverse for Teams now being included with all Office 365 / Microsoft 365 subscriptions, using both Teams and Power Apps together opens up interesting new possiblities. Read more about the limitations and opportunities of Dataverse for Teams in our earlier blog post.

Leave a Reply