in servicenow, In alm_hardware table, one record state is changes to In use to In stock by the System when i check the history of that record. how to check why this was happened
Assistant
When a record's state in the alm_hardware table changes from "In use" to "In stock" by the system in ServiceNow, it's essential to investigate the cause of this automated change. Here's a step-by-step guide on how to check why this happened:
Review Business Rules:
Go to System Definition > Business Rules.
Look for any business rules that might be associated with the alm_hardware table or related tables that could influence its state.
Pay attention to any conditions, scripts, or actions that change the state field.
Check Scheduled Jobs:
Navigate to System Definition > Scheduled Jobs.
Search for any scheduled jobs that might be designed to update the status of hardware assets.
Examine Workflows:
If workflows are used in your instance, go to Workflow > Workflow Editor.
Check for any workflows that could be triggered on the alm_hardware table and investigate any workflow activities that could change the state to "In stock".
Look into Script Includes:
Navigate to System Definition > Script Includes.
Search for any script include that contains logic for updating the asset state. Look for function calls related to the state field modification.
Check UI Actions:
Go to System Definition > UI Actions.
Identify any UI actions that might update the state field on the alm_hardware table.
Review Import Sets/Transform Maps:
If data imports are a common practice in your organization, check System Import Sets > Import Sets and Import Sets > Transform Maps.
Verify if any recent imports could have triggered the state change.
Update History Tracking:
ServiceNow usually keeps track of changes made to records. Navigate to the alm_hardware table and open the record in question.
Scroll down to the Updates section or check the History tab. This will provide details about when the state was changed and by which process.
Audit Logs:
For more detailed logging, you can check System Logs > System Log > Application Logs and System Logs > Audit Log.
Look for logs around the time when the state changed to understand what process or script executed the update.
Here’s a systematic approach:
Navigate to the alm_hardware table: Open the list of hardware assets and find the specific record.
View the record's history: Use the context menu (hamburger icon) and select History > List. Examine the entries for changes in the state field.
Identify the user: Check who made the change. If it's "System", it indicates an automated process.
Correlate the time of change: Note the exact timestamp of the change to help pinpoint which processes (business rules, workflows, etc.) were active at that time.
Here’s a brief sample script you might add for debugging purposes in appropriate places like Business Rules or Script Includes to capture additional data:
javascript
gs.log('Debug: State transition in alm_hardware table at ' + new GlideDateTime().getDisplayValue(), 'CustomLog');
By following these steps, you should be able to narrow down the exact reason why the state of the hardware record was changed by the system.