ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.TaskAssistant Namespace / TaskItemInfo Class / Guid Property
Example

In This Topic
    Guid Property (TaskItemInfo)
    In This Topic
    Gets the unique guid of the task item.
    Syntax
    public Guid Guid {get;}
    Public ReadOnly Property Guid As Guid
    Example
    Get Task Information - from a TaskProjectItem
    var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
    // if there isn't a project task item, return
    if (taskItem == null)
      return;
    
    string message = await QueuedTask.Run(async () =>
    {
      bool isOpen = taskItem.IsOpen;
      Guid taskGuid = taskItem.TaskItemGuid;
    
      string msg = "";
      try
      {
        TaskItemInfo taskItemInfo = await taskItem.GetTaskItemInfoAsync();
    
        msg = "Name : " + taskItemInfo.Name;
        msg += "\r\n" + "Description : " + taskItemInfo.Description;
        msg += "\r\n" + "Guid : " + taskItemInfo.Guid.ToString("B");
        msg += "\r\n" + "Task Count : " + taskItemInfo.GetTasks().Count();
    
        // iterate the tasks in the task item
        IEnumerable<TaskInfo> taskInfos = taskItemInfo.GetTasks();
        foreach (TaskInfo taskInfo in taskInfos)
        {
          string name = taskInfo.Name;
          Guid guid = taskInfo.Guid;
    
          // do something 
        }
      }
      catch (OpenTaskException e)
      {
        // exception thrown if task file doesn't exist or has incorrect format
        msg = e.Message;
      }
      catch (TaskFileVersionException e)
      {
        // exception thrown if task file does not support returning task information
        msg = e.Message;
      }
      return msg;
    });
    
    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(message, "Task Information");
    Get Task Information - from an .esriTasks file
    // TODO - substitute your own .esriTasks file
    string taskFile = @"c:\Tasks\Get Started.esriTasks";
    
    string message = await QueuedTask.Run(async () =>
    {
      string msg = "";
      try
      {
        // retrieve the task item information
        //At 2.x -
        //TaskItemInfo taskItemInfo = await TaskAssistantModule.GetTaskItemInfoAsync(taskFile);
        TaskItemInfo taskItemInfo = await TaskAssistantFactory.Instance.GetTaskItemInfoAsync(taskFile);
    
        msg = "Name : " + taskItemInfo.Name;
        msg += "\r\n" + "Description : " + taskItemInfo.Description;
        msg += "\r\n" + "Guid : " + taskItemInfo.Guid.ToString("B");
        msg += "\r\n" + "Task Count : " + taskItemInfo.GetTasks().Count();
    
      }
      catch (OpenTaskException e)
      {
        // exception thrown if task file doesn't exist or has incorrect format
        msg = e.Message;
      }
      catch (TaskFileVersionException e)
      {
        // exception thrown if task file does not support returning task information
        msg = e.Message;
      }
      return msg;
    });
    
    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(message, "Task Information");
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also