ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Core.Geoprocessing Namespace / IGPHistoryItem Interface
Members Example

In This Topic
    IGPHistoryItem Interface
    In This Topic
    Get geoprocessing tool history information from a project.
    Object Model
    IGPHistoryItem InterfaceIGPResult Interface
    Syntax
    public interface IGPHistoryItem 
    Public Interface IGPHistoryItem 
    Example
    How to access Geoprocessing History
    string openProjectPath = @"D\DATA\IGPHistoryItemTestProject\IGPHistoryItemTestProject.aprx";
    await Project.OpenAsync(openProjectPath); 
    MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map", StringComparison.CurrentCultureIgnoreCase));
    
    var map = await QueuedTask.Run(() => mapProjItem.GetMap());
    var ftrLayer = map.Layers[0] as FeatureLayer;
    string tool1 = "management.GetCount";     
    var args1 = Geoprocessing.MakeValueArray(ftrLayer);
    var env = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);          
    GPExecuteToolFlags executeFlags = GPExecuteToolFlags.AddToHistory;
    var t = await Geoprocessing.ExecuteToolAsync(tool1, args1,env,null,null,executeFlags);
    
    IEnumerable<IGPHistoryItem> hisItems = Project.Current.GetProjectItemContainer(Geoprocessing.HistoryContainerKey) as IEnumerable<IGPHistoryItem>;        
    
    String hitemID="";
    String hitemToolPath="" ;
    IGPResult hitemGPResult=null;
    DateTime hitemTimeStamp;
    
    foreach (var hitem in hisItems)
    {
        // common IGPHistoryItem and Item properties
        hitemID = (hitem as Item).ID;
        hitemToolPath = hitem.ToolPath;
        hitemGPResult = hitem.GPResult;
        hitemTimeStamp = hitem.TimeStamp;
    }
    
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.1 or higher.
    See Also