Thursday, January 10, 2013

Customer Care Accelerator - UI Automation using Workflows (HAT)

Customer Care Accelerator (CCA) for Microsoft Dynamics CRM focuses on delivering contact centre based functionality, such as the ability to create a unified desktop by combining different line of business applications and displaying it in a single user interface.  
I have promised earlier to write more about CCA, but was quiet busy with my projects. Apologise for the delay caused. Today I am trying to explain more about how to use Windows Workflow Foundation within CCA. CCA framework provides a Hosted Application Toolkit which supports Windows Workflow Foundation to do UI Automation. The following scenario is a simple workflow activity to do an automated search using CCA inside Bing.
Add a new Uii project called Web Application and call this “Bing”. The name of this web application and the Uii Hosted application record in CRM should be the same so that you don’t have any conflicts during building the Workflow.
Click “OK” on the new project window and you will see the following “Application Properties” window popup. Specify the URL of the web application you are trying to automate.

This will create a visual studio project in your solution and will have 2 xml files added to the project.

Now right click on the project and select Inspect from the dropdown. It will open the Bing web application in an IE and the UI Inspector to find the controls. Press Control key and move the mouse over to the Control which needs to be captured, here in the current solution it’s the Bing Search text box control and name it as “SearchTextbox” (this is my input control for my search). Click Add Control button in the UI Inspector to add the control to the Initstring.xml. The UI inspector will capture the HTML DOM to navigate to the Search Text box. Now press the control key again and move the mouse over to the search button and the UI inspector will capture the Bing Search Button DOM and is named as “SearchButton”. Now Click on Add Control to add the search button HTML DOM path to the Initstring.xml and Click “Done” in the UI Inspector to finish the Inspection.

Now open the Initstring.xml file to verify if it’s updated correctly. The xml file will be seen updated with the DOM to access the controls within the Bing application.

Now go to the Workflow project and add new Workflow Activity and name it as “BingSearch.xaml”.

Open the “BingSearch.xaml” and add a Sequence diagram from the tool box.

Once the sequence component is added into the designer, add other components required as a part of the workflow execution logic. In the current scenario, I will use the controls such as “ControlFinder”,”SetControlValue” and “ExecuteControlAction” for my automation. The “ControlFinder” will check if the Search text box is available and will return true. The “SetControlValue” will set the value as “Microsoft” and “ExecuteControlAction” will trigger the Search button action.

Once the controls are placed and build the solution and reference the project to the “AgentDesktop” project. Now create a Hosted Web Application in CRM with the following properties set.
The Automation binding set should be the Initstring.xml which has been created initially. Only the “DataDrivenAdapterBindingsCollection” tag needs to be copied into the Automation Bindings area from the Initstring.xml file.
Now, save the “Bing” record in CRM Uii Hosted Applications and open the default Uii Action for the Bing record.  Change the Automation Mode to “Use Workflow Assembly” and select the check box “Run Asynchronously” to run the workflow asynchronously. Now specify the Workflow Assembly Namespace Uri including the workflow name comma separated by the namespace of the project as shown below.

Save and close the record and run the AgentDesktop project. When the Bing application is launched in the tab, the workflow will run the automation and will do a search for the text “Microsoft” within bing web application.

Hope this helps you with building a HAT automation using Workflows. Good Luck!