Share via


Dynamics AX2012: Integrating Managed Controls with Task Recorder

Integrating Managed Controls with Task Recorder:

Task Recorder Overview:

Task Recorder is a feature of Dynamics AX that is used extensively by partners and customers to create process or learning documents for customer specific scenarios.

With Task Recorder, the user can document the specific steps for completing a task in AX. In record mode, Task Recorder creates a "step by step" record of user actions in a textual
format that is then used to generate PowerPoint or Word documents, complete with screen shots as appropriate.The task recorder control panel can be found in Tools>>Task Recorder

 

Managed Control Integration with Task Recorder Overview:

Previously, every new control added to Dynamics needed to extend the sysTaskRecorder base class by creating a specialized class with methods that supported the types of events that they wanted recorded, and called
those methods when the event occurred. In addition, Task Recorder document generation needed to be extended with knowledge of the new base class in order to properly create documents based on the new events.

The process wasn't documented and the process was cumbersome and therefore externally added controls via ActiveX were never included in Task Recorder recordings.

 

With the introduction of new managed controls in Dynamics AX2012, we created a simplified integration pattern, one in which a simple "generic" Task Recorder class could be used by any control.

 

This new class allows all new controls without specialized event recording needs to simply call into the generic 'record event' class, passing in a descriptive string, with supporting data if desired. 

Example:

Create an X++ event handler for a managed control event. In this example, we'll call task recorder to "record" that event.  

1) Add an
X++ event handler to respond to events raised by your control.

You can define an X++ method and designate it as an event handler for events raised by your control. In this example, we're adding a form method.
While it's possible to use class methods, it's recommended that you use form methods. 

In this example, we're passing in the ManagedHost instance... if you do this, a screenshot of the control will be taken, if no control is passed, no screenshot is taken.

 

void ManagedHost_SelectedDateChanged(System.Object sender, System.Windows.Controls.SelectionChangedEventArgs e){    // the control doesn't need to be cast here... it's also available as a form global    System.Windows.Controls.DatePicker datePicker = sender as system.Windows.Controls.DatePicker;

    str dateChangedValue;

    if (datePicker )

    { dateChangedValue = datePicker.get_Text();        SysTaskRecorder_Eventing::fire_UserSpecified(                       strfmt("The user has changed the date to %1.", ManagedHostName), ManagedHost);    }}

 2) Hook up the managed event handler

It is recommended that you define all of your event handlers in the init method of the form.

 // Glue code:
Hook the managed controls event to an X++ Event Handler:

   ManagedHost.add_SelectedDateChanged(new ManagedEventHandler(this, 'managedEventHandler_RecordDateChanged' ));

 

Note on performance: Task recorder event SysTaskRecorder_Eventing::fireUserSpecified() is a expensive operation. It creates a XmlDocument and takes a screen capture. So we should fire the event
only when task is being recorded and should not call it for normal forms execution. To check if task is being recorded, use SysTaskRecorderEventManager::parmRecording() and if true, then call the
event.