--- title: "system.eam.queryAgentHistory" description: "Returns a list of the most recent agent events." --- # system.eam.queryAgentHistory > Returns a list of the most recent agent events. This function is used in **Python Scripting**. ## Description ## Client Permission Restrictions This scripting function has no [Client Permission](projects\project-properties\project-properties.md#client---permissions) restrictions. ## Syntax `system.eam.queryAgentHistory(groupIds, agentIds, startDate, endDate, limit)` ### Parameters | Type | Parameter | Description | |---|---|---| | List | `groupIds` | A list of groups to restrict the results to. If not specified, all groups will be included. | | List | `agentIds` | A list of agent names to restrict the results to. If not specified, all agents will be allowed. | | Date | `startDate` | The starting time for history events. If null, defaults to 8 hours previous to now. | | Date | `endDate` | The ending time for the query range. If null, defaults to "now". | | int | `limit` | The limit of results to return. Defaults to 100. A value of 0 means "no limit". | ### Returns **Dataset** - A dataset with columns id, agent_name, agent_role, event_time, event_category, event_type, event_source, event_level, event_level_int, and message, where each row is a new agent event. ### Scope All ## Code Examples ```python title="Example #1" # This script will loop through each row of the dataset and grab out every value from that row and assign it to a matching variable. Those variables can then be used in some way. results=system.eam.queryAgentHistory() for row in range(results.rowCount): eventId=results.getValueAt(row, "id") agentName=results.getValueAt(row, "agent_name") agentRole=results.getValueAt(row, "agent_role") eventTime=results.getValueAt(row, "event_time") eventCategory=results.getValueAt(row, "event_category") eventType=results.getValueAt(row, "event_type") eventSource=results.getValueAt(row, "event_source") eventLevel=results.getValueAt(row, "event_level") eventLevelInt=results.getValueAt(row, "event_level_int") message=results.getValueAt(row, "message") #Can include some code here to use the variables in some way for each row. ``` ```python title="Example #2" # This script will loop through each row of the dataset and grab out every value from that row and assign it to a matching variable. Those variables can then be used in some way. results=system.eam.queryAgentHistory() for row in range(results.rowCount): eventId=results.getValueAt(row, "id") agentName=results.getValueAt(row, "agent_name") agentRole=results.getValueAt(row, "agent_role") eventTime=results.getValueAt(row, "event_time") eventCategory=results.getValueAt(row, "event_category") eventType=results.getValueAt(row, "event_type") eventSource=results.getValueAt(row, "event_source") eventLevel=results.getValueAt(row, "event_level") eventLevelInt=results.getValueAt(row, "event_level_int") message=results.getValueAt(row, "message") #Can include some code here to use the variables in some way for each row. ```