Skip to main content

Generating Notifications

FinanSys Apps can interact with Microsoft Teams in various ways as part of a process. In this example we are going to generate a Teams message in a specified Teams channel so all Team members who have elected to receive notifications for that channel will receive a Teams message with a link that takes them to the FinanSys Apps task that generated the message. This could be alerting them of a task that needs their approval, or just a message for information purposes.

MS Teams Configuration

The first step is to create an 'Incoming Webhook' in the channel to which the messages are to be posted. Within Teams, click on the relevant channel and from the '...' icon to the right of the channel select 'Connectors'. From here click the 'Configure' option next to 'Incoming Webhook'. Give the webhook a name and upload an image if you want to (this is displayed to the left of the main message that a user will see). A URL will be generated that is needed in the next stage of the process, click on the option to copy this to the clipboard and then save your webhook.

 alt image

tip

To edit an existing webhook click on 'Configured' on the left of the connectors screen. This then allows you to view and amend the connectors that have been created for that teams channel.

FinanSys Apps Process Step

We now need to add a step to the FinanSys Apps process for the relevant app to send the message at the appropriate point in the process. This is a 'SendHttpRequest' step and should be included just before the step it relates to, so if you are sending a message to say that an item requires approval then this should be set just before the approval step referred to.

The URL should be pasted from the one you copied as part of the MS Teams configuration and the method should be set to 'Post'. The content type is Javascript, but we will actually be sending a string of JSON in the format required by MS Teams. The exact content of this will depend on what you want the message to say, but you will probably want to bring in information from the current record and construct a clickable link to that record using the methods described in the relevant sections of this help. There are resources on the Microsoft website and elsewhere on the web that give full details of whats possible in a Teams message, but the following example JSON works with a current record of 'CurrentRecordTeams' to bring in information from that record such as the person who initiated the transaction and provide clickable links to both the specific transaction and to all outstanding items on that specific app.

	`{
"@context": "https://schema.org/extensions",
"@type": "MessageCard",
"potentialAction": [
{
"@type": "OpenUri",
"name": "View This Task",
"targets": [
{
"os": "default",
"uri": "https://demo.finansysapps.com/item-editor/` + (JSON.parse(CurrentRecordTeams.Result).application_module_information).id + `/` + JSON.parse(CurrentRecordTeams.Result).id + `/edit?from=datatable"
}
]
},
{
"@type": "OpenUri",
"name": "View All Tasks",
"targets": [
{
"os": "default",
"uri": "https://demo.finansysapps.com/module/` + (JSON.parse(CurrentRecordTeams.Result).application_module_information).id + `?from=sidebar"
}
]
}
],
"text": "` + JSON.parse(CurrentRecordTeams.Result).record_created_by + ` wants you to approve a ` + (JSON.parse(CurrentRecordTeams.Result).application_module_information).display_name + `",
"themeColor": "0072C6",
"title": "You have a new task in FinanSys Apps"
}`
tip

Copy and paste the above into the 'Content' area in the FinanSys Apps process step and then amend as necessary. Note the use of the backtick ` character, this 'template literal' means we can format the script over several lines which makes it easier to read than having everything in a single wrapped line or splitting it over multiple lines of code.

Note that this is a string value in JSON format where fixed segments are contained within single quotes and dynamic parts such as the 'record_created_by' are dropped in using formulas such as:

  • JSON.parse(CurrentRecordTeams.Result).record_created_by +

 alt image