I am updating a workflow that I built a little while ago that lets some people reset passwords in AD. Our process has been updated that for some instances we have to notify a person’s manager when we reset their password.
Our workflow is kicked off via MS Teams using
!reset-password <sam/upn>
I plan on adding two parameters: -notify and -ticket
I know I could just require having them in a specific order, but I know some people will keep forgetting.
So, question is, instead of looping the words property through a loop and checking each item value to see if these two values exist, is there a better way to determine if those two parameters were included in the trigger? Should I just dump the value of the trigger.words to an artifact and then run the artifact through a regex action?
This is the same workflow that is used for account clean up so the list could be rather long, which is why I want to avoid having to loop through an entire array.
Thanks!
Sean
*Edit: added what the command would look like with the parameters sent via Teams
It’s a good idea for users to follow the same format for executing the workflow each time and also to notify them when parameters are in the wrong order. It would then be best to extract those using the pattern match step using the variable feature. It would then look something like this:
I do this all the time, but with pattern matching.
My initial Regex is (?i)^!reset-?password
I then have a pattern match of
-t(icket)?(=|:|\s)“?{{TicketNumber:/[^\s”]+/}}
On catch, make sure you run the remove html tags from the returned string, Teams inserts these when you copy/paste and will break your ^
The problem generally arrises when users copy/paste text into the message in Teams. You can try having them “paste without formatting.” To paste text without formatting on both Mac and Windows, use Ctrl + Shift + V on Windows and Cmd + Shift + V on Mac. Otherwise, you can use the HTML plugin to strip the HTML from the text before running the message through pattern match.
I cannot trust people to paste correctly so I use the HTML plugin like suggested, this will slow down the workflow slightly but saves you from people reaching out saying that isn’t working. I also try to account for the different ways that people might enter the argument to avoid human error
If you want to control how people enter the command and give them a GUI like interface, look into adaptive cards. I have that trigger on the ICON username, it presents a simple GUI where they copy and paste into that form, it then formats the command correctly. This allows you to manually enter the command (e.g. have another Workflow post a command for you, we use this when a Workflow wants to automatically reset a password, instead of the Workflow calling it, it sends the Teams command) or a user can use the GUI
I am trying to do that right now and it sort of feels like an effort in futility. Every time I think I have it figured out, they figure out something new and novel to cause a problem. lol.
I had to make assumptions on your user names and your ticket format, but assuming your usernames do not contain numbers, and your tickets do contain numbers, with JQ you can make your workflow work. I tested with the following scenarios and everyone of them works.