DEPNotify - Prefill instead of Placeholder

jrossowgreenber
New Contributor

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?

12 REPLIES 12

mlavine
Contributor

@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.

jrossowgreenber
New Contributor

Figured. Hmm, that's an interesting suggestion. I think I'll investigate that. Thanks!

Hugonaut
Valued Contributor II

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?

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

marklamont
Contributor III

I have to ask @jrossowgreenberg why you need the user/tech to do this when you have the information from your script anyway?

jrossowgreenber
New Contributor

@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.

marklamont
Contributor III

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.

Hugonaut
Valued Contributor II

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 ..

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

jp2019
New Contributor III

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:

  1. UserName - text field to enter the user's name.
  2. Departments - The department list we have is out of control, so I would like a text field where to enter the departments
  3. Campus - Under Computer Management-->"Extension Attributes" I created "Campus" is it possible to populate this during registration? it is a short list of 5 campus locations so it could be a popup or a text field.
  4. Room - A text field to enter the office number. Any help will be greatly appreciated.

Hugonaut
Valued Contributor II

@jp2019

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 =)

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

jrossowgreenber
New Contributor

@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!

jp2019
New Contributor III

Thank You. How can I change the drop down popup labels to text boxes instead?

TheUnknownIT
New Contributor II

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