Create HAT automation
You can use the Hosted Application Toolkit (HAT) automation activities to create automations for your hosted application project. You can use User Interface Integration (UII) inspector to make the controls of an application available for use in automation. Although an automation is started by an action defined on an application, it can access defined controls in all applications that run in the session. Automations can also interact with non-automation enabled applications through activities such as DoAction or Apppplication Integration Framework (AIF) context activities. More information: Types of HAT automation activities
Before you add automation to your application, ensure that you have inspected all the required controls in your application. To do so, see Use UII inspector to create bindings for the hosted application.
In This Topic
Create HAT automation
Configure an action to run the automation
Verify the HAT hosted control with automation
View sample automations
Create HAT automation
Open the application project that you created earlier using HAT where you want to add automations. More information: Use HAT Software Factory to create a hosted application. You can also create a workflow in a separate project, and then add it to your existing hosted application created using HAT.
In Solution Explorer, right-click the project name, and select Add > New Item.
In the Add New Item dialog box, select Visual C# > Workflow in the left pane, select Activity as the project type, specify an appropriate name, and then click Add.
This adds the activity workflow (XAML) in your project, and opens up the XAML in the workflow activity designer area where you can drop the HAT automation activities as well as other activities to design your automation.
Create your automation using the HAT activities, save your project, and then build it.
The next step is to configure an action for the HAT application that you created earlier, and then associate the action with the automation that you just created.
Configure an action to run the automation
In this section, we will configure an action on the application to associate it with the automation that we created in the previous section.
Open the HAT application project in Visual Studio, if it’s not already open. More information: Use HAT Software Factory to create a hosted application.
In Solution Explorer, right-click the HAT application project name, and select Action Configuration.
In the Action Configuration dialog box, specify the action name and other details, as required. For information about these fields, see Configure an action for the hosted application.
Under Automation, from the Mode list, select Use Workflow Assembly or Use Workflow XAML to associate an automation with the action.
Click Select Workflow to specify the automation.
In the Workflow Selector dialog box, expand your project name, and then select the workflow (.xaml) to be associated with the action, and then click OK.
If you selected:
Use Workflow Assembly in step 4, the type information is populated in the Type field for the selected automation (workflow).
Note
As the absolute path to the workflow assembly is not mentioned in the Type field, you must copy the workflow assembly file in the Unified Service Desk client installation directory to test and use the hosted application and the automation.
Use Workflow XAML in step 4, the workflow XAML is populated in the XAML field for the selected automation (workflow).
If you want the run automation in an asynchronous mode, select the Async check box. Automation can be executed synchronously or asynchronously.
In synchronous mode, the automation runs in the Unified Service Desk user interface (UI) thread, and blocks the UI until it is finished. Blocking the UI can be useful as it allows the application UI state to be updated in isolation. To prevent the UI from appearing unresponsive, keep automation run times as short as possible.
In asynchronous mode, the automation doesn’t run in the Unified Service Desk UI thread until it needs to interact with the UI.
Select Save to create the action to trigger the automation.
Save the project, and build (Build > Build Solution) it.
Verify the HAT hosted control with automation
Deploy the HAT application to Unified Service Desk on the Microsoft Dynamics CRM server. More information: Deploy the hosted application to Unified Service Desk
Copy the required files (workflow and HAT application assemblies) to the Unified Service Desk client application directory (typically C:\Program Files\Microsoft Dynamics CRM USD\USD).
Run the Unified Service Desk client, and use Debugger to test your HAT hosted application and the action with automation. In the Debugger tab, click the down arrow above the Action Calls tab to display the area where you can test action calls and User Interface Integration (UII) actions.
Click the Direct Action tab:
Select your hosted control and action that you want to verify.
Click the run icon to test it.
For more information about using the Debugger hosted control, see Debug issues in Unified Service Desk in the Unified Service Desk Administration Guide.
Tip
To debug the automation, start Visual Studio as administrator, open your HAT application project, and set the Unified Service Desk client executable file (UnifiedServiceDesk.exe) as the external startup program in the properties of the project. Also, set the build output path of the project to Unified Service Desk client installation directory. Every time you debug the project, the assemblies will be copied over to the Unified Service Desk client installation directory, and the client will start.
View sample automations
Download the UII SDK, and extract it.
In the <ExtractedFolder>\UII\SampleCode\UII\Hat\QsAutomationProject folder, open the Microsoft.Uii.QuickStarts.QsAutomationProject.csproj file in Microsoft Visual Studio.
Fix the missing assembly references in the project by setting the reference path of your project (Project > [Project] Properties > Reference Paths) to the <ExtractedFolder>\UII\Bin\UII folder or to the Unified Service Desk client application directory (typically C:\Program Files\Microsoft Dynamics CRM USD\USD).
Build the project (Build > Build Solution) to view the sample automations (XAML). After the project is built successfully, double-click a XAML file in Solution Explorer to view the automation definition.
See Also
Concepts
Use HAT automation activities
Types of HAT automation activities
Configure an action for the hosted application
Unified Service Desk
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.