Posted on 07-15-2019 11:12 AM
I'm trying to find a way to modify DEPNotify so that a text field is pre-filled. Specifically, I'm using the DEPNotify Starter script here: https://github.com/jamf/DEPNotify-Starter
The first text field is asking for the Computer Name. I want to prefill the text box with the last 8 digits of the Macs serial. Like this:
-1234ABDC
I have the code to grab this:
serialNumber=$( system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4; }')
shortSerial=${serialNumber: -8}
DEPNotify starter supports placeholders but when the user clicks into the field the placeholder disappears. Anyone know of an easy way to get that text to stay?
Posted on 07-15-2019 11:54 AM
@jrossowgreenberg, you aren't going to be able to change that functionality without modifying the actual app using Xcode. That being said, once you retrieve the data that the user filled in there you could append the serial number on and use that.
Posted on 07-15-2019 12:24 PM
Figured. Hmm, that's an interesting suggestion. I think I'll investigate that. Thanks!
Posted on 07-15-2019 01:09 PM
Took a look at the script, thinking outside the box
Lines 230 - 234 & General Concept Below. Its not autopopulated but will be a quick and easy copy/paste for deployment team
https://github.com/jamf/DEPNotify-Starter/blob/master/depNotify.sh
# Text Field Label
REG_TEXT_LABEL_1="Copy & Paste $shortSerial Below"
# Place Holder Text
REG_TEXT_LABEL_1_PLACEHOLDER=$shortSerial
Have you tried something like this?
Posted on 07-16-2019 04:08 AM
I have to ask @jrossowgreenberg why you need the user/tech to do this when you have the information from your script anyway?
Posted on 07-16-2019 04:40 AM
@Hugonaut Good suggestion. I haven't thought of that. The only issue is that you can't copy the Field Label. I can do something like below and have the tech manually type out the short serial into the field.
# Text Field Label
REG_TEXT_LABEL_1="Computer Name (suggested: DEPT-$shortSerial)"
@marklamont Traditionally, our standard naming convention is DEPT-SHORTSERIAL however, there are cases where a more identifiable name is necessary; DEPT-PERSON or DEPT-KIOSK1 etc. I want to suggest -SHORTSERIAL but maintain some level of flexibility. @Hugonaut 's suggestion gets me close.
Posted on 07-16-2019 10:19 AM
just a suggestion use a pop up for DEPT, a popup for kiosk or person then the optional text box can be used for their name or kiosk number then just work out what the result is based on what gets entered, and if bits are missing default the name back to your dept-serial. you can always sort out odd names later with a policy.
But as an extra final thought maybe time to justify tradition and find out whether the info you need can be obtained any other way or is even actually relevant.
Posted on 07-16-2019 10:41 AM
Hmm, @marklamont is on the right path, you could always pass the information automatically to the computer name & to JAMF without using an interactive prompt ..
Posted on 07-16-2019 12:26 PM
Hi, I'm using the DEPNotify Starter script here: https://github.com/jamf/DEPNotify-Starter. Can someone suggest how to modify the script in order to achieve this out come:
I am using the pop up for the Building location. But I would like to use the other fields as text fields to enter text at registration for and have it populate:
Posted on 07-16-2019 12:34 PM
The script has built in, unused popups for exactly this type of thing, regarding your drop down menu for example, Lines 384 - 411 of Jamfs depNotify starter contain the following.
# Popup 4 - Code is here but currently unused
#######################################################################################
# Label for the popup
REG_POPUP_LABEL_4=""
# Array of options for the user to select
REG_POPUP_LABEL_4_OPTIONS=(
"Option 1"
"Option 2"
"Option 3"
)
# Help Bubble for Input. If title left blank, this will not appear
REG_POPUP_LABEL_4_HELP_TITLE="Dropdown 4 Field"
REG_POPUP_LABEL_4_HELP_TEXT="This dropdown is currently not in use. All code is here ready for you to use. It can also be hidden by removing the contents of the REG_POPUP_LABEL_4 variable."
# Logic below was put in this section rather than in core code as folks may
# want to change what the field does. This is a function that gets called
# when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!
REG_POPUP_LABEL_4_LOGIC (){
REG_POPUP_LABEL_4_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_POPUP_LABEL_4")
echo "Status: $REGISTRATION_BEGIN_WORD $REG_POPUP_LABEL_4 $REGISTRATION_MIDDLE_WORD $REG_POPUP_LABEL_4_VALUE" >> "$DEP_NOTIFY_LOG"
if [ "$TESTING_MODE" = true ]; then
sleep 10
else
sleep 10
fi
}
above this (Lines 355 - 382) is another unused option, you could use this for populating a response for Rooms. all you need to do is modify these lines to fit your needs =)
Posted on 07-17-2019 06:16 AM
@marklamont This is exactly what we ended up doing. I presented a couple of options to our team and based off the feedback we decided to go with a field that simply asks for a department prefix. DEPNotify then appends the short serial number and sets the computer name. A popup doesn't make sense for us because we have so many different departments we support, maintaining that list would be a headache. Thanks all for your feedback!
Posted on 07-18-2019 11:45 AM
Thank You. How can I change the drop down popup labels to text boxes instead?
Posted on 02-26-2020 09:55 AM
Hello All,
This is how I've been going about auto-naming my computers using the last 7 of the serial number, the department that the user selects and a D or L for laptop or desktop. I am then added this towards the end of the DEPNotify Starter script.
IS_LAPTOP=`/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"`
serialNumber=$( system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4; }')
if [ "$IS_LAPTOP" != "" ]; then
/usr/local/bin/jamf setComputerName -name "${REG_POPUP_LABEL_2_VALUE}-L${serialNumber: -7}"
else
/usr/local/bin/jamf setComputerName -name "${REG_POPUP_LABEL_2_VALUE}-D${serialNumber: -7}"
fi