(seriously amateur scripter) looking to upgrade how we manage device naming.
Our naming policy is not complicated, Department-Building-Tag#, and our current script requires us to maintain a separate list of data to populate a dialog box that lets the user select from the available options:
set Department to (choose from list {"AAA", "BBB", "CCC", "DDD", etc.
But that means anytime there is a change in department structures, we need to update the Jamf>Network>Departments information, as well as the script.
I am hoping to use API commands to grab the current list of departments when the Naming Policy is triggered something like:
departmentList=$(curl -su username:password\\
"https://url/JSSResource/departments" \\
-H "accept: xml/text" \\
| xmllint -format - \\
| awk '/name/ {print}' \\
| awk -F '[><]' '{print $3}')
This gets me the data in a list, but I can't figure out how to (or if it is possible to) prompt the user to select from a list just by calling the variable:
...
set Department to (choose from list $departmentList \\
for example.
Is it possible to do this?