Hi there, this may be a weird question, but we've noticed a sort of 'Bug'.
We have scripts to backfill certain fields in our data that may be inaccurate or unfilled. For example, we have a UUID field for each for assets. We have a script to run to update all the existing assets without UUIDs, and it works well, however...
We've noticed that the Activity Log/Panel inaccurately shows the user who updated the record. It will always show the current logged in user as the user who did the change, regardless of who's logged in:
In this picture, the current user appears as the one who did the changes to UUID, but that is false, the changes were executed through a script from the server terminal.
This causes our users to get confused, so we started looking into why it was happening.
When investigating the priv_change table, which holds these changes, we see that the user_id and userinfo fields are blank:
So my question is, is there a way to programmatically set a userid for these changes? I'm using the DBObject methods to read and set this data. We would like to be able to create a user for these automatic updates, so that our endusers don't experience the bug when there is no user associated to the change.
Here are the script contents:
<?php/*Make sure you are in the web/ folder, and then run this command, changing the class name as an argument:php "scripts/php-scripts/backfilluuid.php" FunctionalCI*/if(!isset($argv)||count($argv)<2){echo'No argument provided - please provide the class name as an argument';die();}$className=$argv[1];require_once'approot.inc.php';require_onceAPPROOT.'/application/application.inc.php';require_onceAPPROOT.'/application/itopwebpage.class.inc.php';require_onceAPPROOT.'/application/wizardhelper.class.inc.php';require_onceAPPROOT.'/application/startup.inc.php';$oFilter=newDBObjectSearch($className);$oSet=newDBObjectSet($oFilter);$oObjects=$oSet->ToArray();foreach($oObjectsas$key=>$aObject){$UUIDv4='/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i';if(!preg_match($UUIDv4,$aObject->Get('ods_uuid'))){$aObject->Set('ods_uuid',ODSHelper::UUIDv4());}$aObject->DBUpdate();}?>
Last edit: Jacques Dancause 2025-10-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there, this may be a weird question, but we've noticed a sort of 'Bug'.
We have scripts to backfill certain fields in our data that may be inaccurate or unfilled. For example, we have a UUID field for each for assets. We have a script to run to update all the existing assets without UUIDs, and it works well, however...
We've noticed that the Activity Log/Panel inaccurately shows the user who updated the record. It will always show the current logged in user as the user who did the change, regardless of who's logged in:
In this picture, the current user appears as the one who did the changes to UUID, but that is false, the changes were executed through a script from the server terminal.
This causes our users to get confused, so we started looking into why it was happening.
When investigating the priv_change table, which holds these changes, we see that the user_id and userinfo fields are blank:
So my question is, is there a way to programmatically set a userid for these changes? I'm using the DBObject methods to read and set this data. We would like to be able to create a user for these automatic updates, so that our endusers don't experience the bug when there is no user associated to the change.
Here are the script contents:
Last edit: Jacques Dancause 2025-10-31
Solved! I found it in the core itop code. It's CMDBObject::SetTrackInfo and SetTrackUserId.
Last edit: Jacques Dancause 2025-10-31