Discovery pattern ext to populate custom 'most recent logged on user'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 09:53 AM
Hi all, I'm looking for help on a discovery pattern extension that will take the current logged on user and populate a custom field called 'Most recent logged in user' on the Computer CI record.
The rationale for doing this is that the 'Assigned to' field on the CI and corresponding Asset record gets overwritten when discovery runs and finds the current logged in user. Sometimes the current user is not the assigned owner of the device.
The approach I have taken is to copy steps 2.58 and 2.59 from the Windows OS desktops pattern into a new extension. I then changed the target field on 2.59 to point to a new custom field 'u_most_recent_user' which has the same type and properties as the original 'assigned to' field.
I can see from the CI history that it is trying to update the field but it still appears blank. I'm also curious about how the Transform table function updates the existing 'Assigned to' which is a reference field with 'domain/username' but then shows as populated with a 'Name'.
Any thoughts to point me in the right direction would be appreciated.
Thanks in advance
- Labels:
-
Discovery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 05:42 PM
Hi,
In my lab instance, I see a step in the Windows OS - Desktop pattern called "11. Insert System, OS and CPU data to cmdb_ci_computer" where the values from various transformed tables are then populated into the $cmdb_ci_computer table, including the assigned_to attribute. In that step, the assigned_to is populated from "$computerInfo[1].UserName" which is earlier populated from teh "9.3. set assigned to if empty" step, which gets it from the assigned_to table. It looks like you might need to replicate that behaviour also - so write the new value from $u_most_recent_user to the $cmdb_ci_computer table, into the new attribute that you have created for most recent user.
I haven't done much pattern work lately, so I'ma little rusty, but hopefully that is accurate and helps 🙂
Regards,
David