Hello
I am currently trying to design a Sharepoint list for work permits in tandem with a Power Automate workflow. I have been trying to get a simple workflow to generate a unique value that is the highest value in the column + 1. For example I am making a new entry and the last permit number was #1002 so when I create a new entry the permit number will be #1003.
Here is the tricky part, I have different types of permits that all need to have serial numbers constantly having the maximum value generated. So I may have one entry in the list that generates the number work permit while also generating one for a special shutdown permit. Every way that i go about it just becomes an overcomplicated mess.
below are some snippets to help illustrate my problem.



I keep running into problems with data types. what is the simplest way to find the maximum value from a dynamic array variable. I can't use the order by descending then only take the first entry since I will have to search through multiple columns and not every single entry is consecutive from the last entry. I need to be able to define a variable then use the max() expression.
I would be grateful for any insight from anyone experienced with power automate.