Skip to content

Automation

Dominator55 edited this page Apr 22, 2024 · 7 revisions

Power Automate

I am very proficient in Power Automate and I am using it since the year 2018.

Error Handling

In this solution, I have used multiple flows and I've set up a rather solid foundation for error handling and reporting. All flows have Try-Catch error handling and all of them call the catch flow which will gather information about the parent flow run and send an email report to a list of users which is set up in an environment variable. This email will contain the flow name, the error message and a link to the flow run.

On Upsert Non-Conformity - Send Notification

This flow triggers on creation or update of Non-Conformity. It initializes variables, sets the title and body of the notification based on whether the record was updated or created and sends the notification to the owner of the record with a link to the record.

This implementation counts with the owner of the non-conformity being a user but I am able to handle this functionality for teams of users also. However, it is a bit more complicated and time-consuming, so I have decided to reduce the complexity by counting with users only.

GeneratePDFforBuilding

This flow triggers when an action is performed. In general, I am not a fan of using a http trigger on flows because the call is not secured. Anyone knowing the URL can trigger the flow an unlimited number of times so it is a security risk regarding DDOS attacks. If we trigger the flow on action (which is empty in this case) trigger, we can easily retrieve input parameters and have a secured way of direct triggering.

This flow retrieves data about all non-conformities concerning a building and fills in a Word template with them. Then converts this template into a PDF and sends the result PDF in an email to the user's personal email address. It could theoretically be downloaded directly into the user's system but the email seems more convenient to me. Please excuse the unpolished template, it was not the main focus of my attention.

Because of the limitation of my trial account (not having an Office 365 connection), I had to supplement OneDrive and Outlook connections with my current work email.

GetProducts_CustomConnectorDemo

Just a simple flow to showcase my ability to work with custom connectors. It only uses the mock endpoint.

Plugins and Code Actions

Plugins are my daily bread. I am not very proficient in advanced concepts of .NET, but plugins, code actions, simple console apps and basic APIs shouldn't be a problem.

General setup

The plugin assembly is set up using an EntityBase class and early bound definitions which are accessible in a shared project. All plugins are of course annotated by tracing.

NonConformityAutonumber

This plugin runs on the PreOperation stage and directly edits the update object. It is filtered on the depth of 1 and runs only on create message and PreOperation stage.

This plugin retrieves an environment variable, increments it and saves the value back into the environment variable. It uses this value as an auto-number for Non-Conformity.

CopyNonConformity

The purpose of this action is to take an input of ID of Non-Conformity and copy the record and all its related entities differing only in an addition of "_copy" in the name. Unfortunately, due to it being more complicated than I've expected and due to time constraints, I wasn't able to get this action running correctly.

Business Rules

I am not using any business rules in this solution. Business rules are useful for some simple FE manipulation and are useful because they run even outside of the bounds of forms but I generally don't like mixing them with client-side scripts. It is also strongly discouraged by MS. If an entity requires more than simple logic, it is recommended to remove all BRs and rewrite them into scripts.

Scripts

I am very proficient in writing client-side scripts. I've written maybe even hundreds of them at this point. I also know how to develop in Typescript and Vue3.

All scripts are written in JavaScript to adhere to KISS. I don't think that Typescript is necessary for client-side scripts. I am using generalization and parameters where possible. The webresources are divided into folders and managed using Webresource Manager from XRMToolBox.

generalFunctions

This library contains 2 simple functions to demonstrate my capability as a client-side scripts developer. ###editableOnCreate Takes executionContext and an array of fields that should be made editable if the form is a create form. From my experience this functionality is very useful for fields that should keep constant value after creation and therefore, I've written the function to be reusable. This script is triggered onLoad of building form on the field "Completion of Construction" and makes the field editable on create.

startIsMoreThenEnd and endIsLessThenStart

These two functions take executionContext and logical names of a start date field and an end date field. They bind these two fields together and throw inline validation errors and change values if they are invalid.

NonConformity formscript

Just a simple function that shows a field based on an optionset value.

copyNonConformity

A function that is used in the "Copy" ribbon button on Non-Conformity form. This script retrieves the entity ID from the primaryControl and calls a bound action.

generateBuildingReport

A function that is used in the "Generate Report" ribbon button on Building form. This script retrieves the entity ID from the primaryControl and calls a bound action.

Custom Connectors

I have made some custom connectors but I haven't had to use them that much so I wouldn't call myself proficient.

Products

Very simple custom connectors using mock endpoint. I didn't have time nor need to create an Azure Function or Custom API to go with the connector. I am not very experienced in this but simple functions and connectors wouldn't be a problem.