
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 06:26 AM
Good morning,
OOTB Discovery runs and populates the assigned_to field on CI's. This is breaking out hardware asset management process and assigning assets to users erroneously if they sign into a shared machine, or a projection computer, kiosk, etc...
I'd like to have Discovery populate a custom field I have created on the CMDB called "u_last_logged_in"
I have found and customized the sensor that identifies computer information with no luck. I have also attempted to change the assigned_to field in the discovery pattern to use u_last_logged_in and I'm just getting a JS error.
I'd like to hear from the community on how you would do this. I feel like there really should already be a last logged on field OOTB and you should have an option to populate this field, or assigned_to. I don't think assuming the recent user of a machine is the asset / CI owner is a very good practice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 08:04 AM
Its running for both.. Ignore the var windowServer. lol
So doesn't look like anything changed here based on what I shared above. So if you want to map to a new field, need to update pattern with custom field and then updated the two lines below in the post script.
Script you need to change the following:
var userName = windowsServer.assigned_to; <-- change "assigned_to" to whatever value you are using in the pattern.
windowsServer.assigned_to = userID; <-- change "assigned_to" to whatever filed you are using to match above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 08:04 AM
Its running for both.. Ignore the var windowServer. lol
So doesn't look like anything changed here based on what I shared above. So if you want to map to a new field, need to update pattern with custom field and then updated the two lines below in the post script.
Script you need to change the following:
var userName = windowsServer.assigned_to; <-- change "assigned_to" to whatever value you are using in the pattern.
windowsServer.assigned_to = userID; <-- change "assigned_to" to whatever filed you are using to match above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 10:15 AM
This did the trick. I'm not sure if the pattern modification was needed, I'm going to experiment with that and go back to OOTB if possible there.
Thanks for the help Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 10:19 AM
It is.. you are in a pre script, so that variable is needed.
see Using Pre/Post Processing Scripts to handle reference fields via Discovery Pattern

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 10:25 AM
I just did some testing and you're right, it is. So for anyone in the future doing this same thing you'll be owning the pre script code and the pattern.
Luckily it's just a couple of edits so if they have some major change to either one of these you can easily use the new version and edit your changes back in.