Push notifications for D365 Field Service Model-Driven App
Now that Microsoft is moving away from the Resco built mobile application (aka Xamarin) and pretty soon (June 2021) all new deployments will use the Microsoft developed Field Service model driven app, we now need to learn how to configure certain things in the Field Service Model Driven App. There are things that you can already do in the Field Service Model Driven app, like use global search as a barcode scanner to find certain records by barcode or QR code like customer assets or products, but other things need to be configured by an admin. In this article I am going to show you how you can create a push notification for the new Field Service Model Driven App when a new booking is created. You can use the same concept to create a Power Automate Flow to also trigger a push notification then the booking is assigned to a different resource. I will be using Power Automate to configure this functionality.
Creating and configuring the Power Automate Flow
It’s important to understand that when you use power automate to create a push notification you can send only the notification to one user at a time. (Or one security group at a time.) To start, sign into https://flow.microsoft.com. Make sure you are in the correct environment. Click on ‘+ Create’ on the left hand side and select ‘automated flow’. The screen that pops open allows you to enter a name for the flow and you can choose a trigger from here. Select the ‘Common Data Service(Current Environment) (soon to be renamed to Microsoft Dataverse)’ trigger. For the action we need to select ‘When a record is created, updated or deleted’, since we want to send a push notification when a new booking is assigned to a resource. When you click the ‘create’ button on the bottom you will be taken to the flow page where you can start configuring the flow. Since I want to create a push notification for each new booking I’ll select ‘create’ as the trigger condition. The entity name is ‘bookable resource bookings’ and the scope I select is ‘organization’. I also set the process to run as the process owner.
I want to put the work order number in the push notification, but in order to do that I need an additional step to get data from the work order. Click ‘+New Step’ and select ‘Get Record’. This is where we will pull data in from the work order that is related to the bookable resource booking. For ‘Item ID’ we need to get the unique ID of the work order. Click your mouse in the ‘Item ID’ field in the flow and search for ‘Work Order’. You should see ‘Work Order (value)’, which is the unique id of the work order we’re looking for. Click on ‘Work Order (value)’ to enter it in the ‘Item ID’ field.
Another thing I need before I can send the push notification is to understand who the resource is. So again I’m going to click ‘+New Step’ and select the ‘Get Record’ option. This time the entity name is ‘bookable resources’ and the item id is the ‘resource(value)’ from the bookable resource booking (When a record is created, updated or deleted). NOTE: It might be a good idea to rename the steps in your flow so that you know which step does what. I.E I renamed this step to “Get a record(Resource)’ .
Now that we have the resource I am going to enter a condition that checks to see if the resource is a user. If this is the case, I want to get the primary email address of the user to send the push notification to. Click ‘+New Step’ and select ‘Condition’. In the first field of the condition I enter ‘User(value)’ from the ‘Get a record’ (bookable resource) step, as this is the unique id of the user who is related to the resource. In the condition step I select ‘is equal to’ and after I click in the third field I click on ‘expression’ and type in ‘null’. Click OK to enter the expression in the third field. In the ‘If no’ section below the condition I click ‘+ Add an action’ and select ‘Get a record’ and select ‘Users’ as the entity name. NOTE: The bookable resource table comes with an out of the box ‘primary email’ field which you could also use to send the notification to, but you would need to make sure you have the correct email address populated in the field. That will make the ‘Get a record (User) step unnecessary.)
In the next step we are going to send the push notification out to the user that is related to the resource that has been booked on the booking. Click ‘+ Add action’ and search for ‘Push Notification’. I am going to use the ‘Send Push Notification V2’ which is currently in preview.
In the ‘Send push notification V2’ action, select the Field Service app as the mobile app as this is the app I want the notification to be sent for. (This is the place the booking will be created.) For the ‘Your App‘ field I select the Field Service mobile app, as this is where I want the notification to be pushed to. The ‘Recipients Item-1‘ is who the recipient is for the notification which is the user’s primary email address, so I select ‘Primary Email’ from the ‘Primary Email’ field from the ‘Get a record(user)’ step.
The ‘Message‘ field represents the message that will be shown to the resource. In this example I only entered the work order number, but obviously you can enter additional information here, like estimated arrival time, location etc.
NOTE: If you add the estimated arrival time, you’ll need to use an expression to translate the time to your own (or the resource’s) time zone. If you want to find out how to do that you can read this article where it’s explained in detail.
The ‘Open App‘ field allows you to configure whether the app should open when the user clicks on the notification. The ‘Entity‘ field represents the table you want to send a notification for. In this case this is the bookable resource booking table. The ‘Form or View‘ field represents which form or view opens when the resource clicks on the notification. From here you can choose which specific view or form opens up. If you’re choose a form you need to make sure you enter the record unique identifier of the record in the ‘Record ID‘ field as well. This would be the ‘Bookable Resource Booking’ from the trigger (When a record is created, updated or deleted). If you pick a view this field can be left blank.
I hope you enjoyed this post! Be sure to check in again next week for a new article or subscribe here to never miss another post!
Comments are Closed