I'm working on a Service Manager based project and discovering capabilities and how to implement features. Tasks is one of the features I'm implementing.

 

The ManagementPack schema has changed to introduce support for features of Service Manager. One of the changes is to the ConsoleTask.

 

ConsoleTask metadata should be placed as a child of the <Presentation/> element, on the same level as any <Form/> elements.

 

The following content is reproduced from the incredibly useful Service Manager team blog (http://blogs.technet.com/b/servicemanager/archive/2010/02/16/brief-overview-of-the-service-manager-console.aspx).

 

It's a very good, definitive guide to using Tasks in Service Manager projects:

 

 

Tasks Pane

The tasks pane items appear based on items selected. So if you’re in the work items space and select the ‘Problem Management’ folder, you will see all tasks that are applicable to the selected folder, then any tasks applicable to the problem management’s parent folder, and then its’ parent in order. They are grouped by the

selections in order. So the current selected items’ tasks will appear first, followed by its parents tasks, followed by the parent’s parent task and so on.

Here is a basic skeleton of how the task definition looks like:

<ConsoleTask ID="[UniqueIDforMyTask]" Target="[ClassThatMyTaskIsTargettedTo]" Accessibility="Public" RequireOutput="false">

        <Assembly>Console!SdkDataAccessAssembly</Assembly>

        <Handler>Microsoft.EnterpriseManagement.UI.SdkDataAccess.ConsoleTaskHandler</Handler>

        <Parameters>

          <Argument Name="Assembly">[Assembly where the task implementation lives]</Argument>

          <Argument Name="Type">[Class of the assembly where the task is implemented]</Argument>

          <Argument>[additional arguments that need to passed for this task]</Argument>

        </Parameters>

      </ConsoleTask>

In the above definition the Aseembly and Handler should remain as is since they are responsible for the launch of your task (instantiating the Type in your assembly)

public class MyClass : Microsoft.EnterpriseManagement.UI.SdkDataAccess.ConsoleCommand

{

public override void ExecuteCommand(IList<NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection<string> parameters)

        {

//this is where your task logic will go

Nodes is the list of selected item(s) –so it could be a folder, view or list of selected item(s) in the grid view

Parameters is the additional arguments that can be passed to the task. This is useful when you want the same task handler to do different things based on parameters passed

}

}

The target of the task can be based on needs, so if you want the task to show up when the selected item in grid view is of a particular class, then you should target it to the class. If you want the task to show up if a folder or view is selected then you should target it to that folder/view.

Folders can also contain tasks. So if you want a task to show up for a selected class and also when a folder is selected, then you can target the task to the class and add a FolderItem mp element that has the ElementID of the task and the folder is the one you want you want the task to show for.

<FolderItem ID="[MyUniqueTaskID]" ElementID="[TheTaskinQuestion]" Folder="[FolderThatTheTaskShouldShowWhenSelected]" />

 

If you want tasks to show up when multiple items are selected, you can use the Multiselect category for this

<Category ID="[UniqueCategoryID]" Target="[TaskIDToBeShownWhenMultipleItemsSelected]" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.MultiSelectTask" />

The value (enumeration) for this lives in the Microsoft.EnterpriseManagement.ServiceManager.UI.Console mp

 

For your custom tasks, you can add a double click category to the task so that it executes when the item is double clicked in the grid view

<Category ID="[UniqueCategoryID]" Target="[TaskIDForDoubleClick]" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.DoubleClickTask" />

 

If you want to add Create View and Create Folder tasks to your folder you can add folder items for them

<!--Create View-->

<FolderItem ID="="[UniqueFolderItemID]" ElementID="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.Task.CreateGridView" Folder="[FolderInQuestion]" />

<!--Create Folder-->

<FolderItem ID="="[UniqueFolderItemID]" ElementID="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.Task.CreateFolder" Folder="[FolderInQuestion]" />

 

If you want to add edit/delete folder tasks to your folder, you can use category for this

<Category ID="="[UniqueCategoryID]" Target="[FolderID]" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.FolderTasks" />

Similary, if you are creating view manually in management pack, you can add ViewTasks

<Category ID="="[UniqueCategoryID]" Target="[ViewID]" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.UI.Console.ViewTasks" />

 

Refresh (F5) task comes for free with every view that gets created.

 

More details can be found in this series:

http://blogs.technet.com/servicemanager/archive/2010/02/11/tasks-part-1-tasks-overview.aspx

Examples of creating task handlers can be found  here:

http://blogs.technet.com/servicemanager/archive/2010/01/04/creating-a-custom-administration-setting.aspx

http://blogs.technet.com/servicemanager/archive/2009/12/30/how-to-write-a-custom-connector-csv-connector-example.aspx