Using Automation to search

Jun 11, 2013 at 5:44 AM
Edited Jun 11, 2013 at 5:49 AM
Hi Everyone,

I am trying to use automation to search from a html page which has a text field and a button and on click of the button, i want to search on two websites in parallel and get the required output on other html page within Agent Desktop.Please guide me as i am new to the automation part of CCA and not getting a clear idea.

Thanks in advance.
Jun 11, 2013 at 8:24 AM
Hi, you want the results of two websearches aggregated in on page ? is that correct ?
Jun 11, 2013 at 9:27 AM
Hi ndi,

Thanks.Yes i want to search on two websites together and aggregate in one page.
Jun 12, 2013 at 7:29 AM
ok, i cannot see a out of the box solution there.

1) You could setup a ASP.NET project which does the search and aggregation in code. This "website" could then be integrated into the AgentDesktop as a WebHostedApplication.

2) You could handle one search and its output with HAT (Automation which fills the text field and press the button for you)

3) Also you could develop a custom Adapter which reacts to an UII ACTION, does the searches and generates the output for the wrapped Browser instance - anyway i dont feel that this is a clean solution

So if you have a CRM on premise setup i would go for Solution 1
Jun 12, 2013 at 11:27 AM
Edited Jun 12, 2013 at 11:28 AM
Hi,

Thanks for your valuable time.I will try the above mentioned solutions.

I have one more issue.

I am trying to read a field from CRM Entity and show the field value in a text-field of a HTML Page through automation, but it's not working as required.
According to me i think there is some problem query string as if i am doing the Action Configuration through VS 2010 and deploying it into CRM. As i have tried hosting web application using same URL and Query string and it's working fine.

Please guide in right direction if i am missing something.

Thanks.
Jun 12, 2013 at 12:25 PM
sorry, i can not help you with deploying action through VS2010... we dont do that.


How do you pass the Entity fieldvalue to your Workflow Assembly ?
Jun 12, 2013 at 2:26 PM
Thanks for you response.

I will elaborate bit more on my scenario, to make it easier for you to understand hope this helps.

Actually i have to read record or a list of fields from CRM save in a variable or get the value from the context and then i have to use that variable in automation of CCA, where the records or the fields that have been read will be displayed in a page(HTML/WEB).
Jun 12, 2013 at 3:36 PM
Edited Jun 12, 2013 at 3:38 PM
Ah, now i understand .. just fire the Action from a HostedControl by code:
 FireRequestAction(new RequestActionEventArgs("HOSTEDAPPLICATIONNAME", "ACTIONNAME", null){Data="VALUE2bPROCESSED");
dont use the third parameter of the RequestActionEventArgs-Constructor. Its also called "data" but is an object you dont have access to in your WorkflowAssembly.
Instead use the Data (string) Property from the RequestActionEventArgs.

-In the Workflow that is triggered through the Automation you can access the passed Data with the HAT-Activity GetActionData

-This Automation delivers the query string .. someting like
 <bar>....<foo>VALUE2bPROCESSED</foo></bar>
-Implement a CodeActivity to parse that Query-string and get your raw value as result
-Use your value to get lucky ;)


does this makes sense to you??

let me know if you need any further help


regards

niklas
Jun 13, 2013 at 4:56 AM
Hi Niklas,

I am not able to understand that where is this Fire Action Code to be used.Can you please guide me in more simple way. I don't have very deep knowledge on this as i have started recently working on it.

Regards,
Jun 13, 2013 at 6:45 AM
Edited Jun 13, 2013 at 6:45 AM
Ok, this could become some kind of a book, so lets make sure we are talking about the same thing first:

You want to achieve the following szenario, right?
Somewhere in your AgentDesktop exists a Button. If you click on it a website appears and one of the fields of the site gets filled with a specific value out of an CRM >Entity.
If thats the Case, what are the steps you have done so far?
  1. Are you able to Receive the entities field value from CRM?
  2. Did you inspect the website with the HAT Inspector to get the Automation XML for filling the field
If i dont get any point right, tell me your whole story (what do you want to achieve; what have you done so far). Its not a big thing - i guess i could implement it in about half an hour. But in the beginning its a bit confusing - so i will guide you the way but you have to dig into that sh**t by yourself ;)

niklas
Jun 14, 2013 at 7:38 AM
Thanks for your help.

I have got my scenario working using the GetContext in Automation and then used SetControlValue to set the value in the other application.Your solutions helped me in getting the idea to work on.
Jun 14, 2013 at 8:34 AM
Yes, the context is a valid alternative. I dont like it for such tasks because of two reasons:
  1. updating the context raises NotifyContextChange on every HostedControl
  2. the data used in the automation is only relevant for the automation and not for the session context in general
But anyway, nice you got it working.
Jun 14, 2013 at 9:52 AM
Edited Jun 14, 2013 at 9:54 AM
Thanks Niklas

As i have discussed at starting of this thread about the web application which has the search functionality and in that i want to search on 2 websites at the same time and show the data aggregated in the page.I have gone through lot many blogs but not able to find out.Can you please provide me link or any alternative to work on this.

I have checked your solution but those are for the single website on which search can be done and the data can be aggregated.

Regards,
Jun 14, 2013 at 10:27 AM
well i thought about it and i have another idea besides the ASP.NET solution:

Just implement a HostedControl. There you can enter a searchstring or alternatively pass the searchstring via a UII Action - depending on your needs.

This HostedControl then does the two web search requests in code.

You have to parse the responses and aggregate it the way you want in some kind of Datastructure.

Then you have multiple options on how to show the search results. I would choose one of the following:

1.You could write some html code and show it in a proper wpf control to get some kind of WebStyle

2.Implement some Custom WPF UserControls or use existing Controls (depending on the data you want to display .. text images .. dont know)

I think thats the way i would do that
Jun 14, 2013 at 1:35 PM
Hi Niklas,

Need your help on this portion :-

Just implement a HostedControl. There you can enter a searchstring or alternatively pass the searchstring via a UII Action.

This HostedControl then does the two web search requests in code.

Can you just tell me how this can be done.

Regards.
Jun 14, 2013 at 2:14 PM
Edited Jun 14, 2013 at 2:17 PM
you mentioned you use VS2010 .. there are Matts Solution Starters available (http://blogs.msdn.com/b/mbarbour/archive/2012/06/15/visual-studio-solution-starters-and-templates-for-cca-uii.aspx) that you can install as Project Templates for VisualStudio

-Create a new Project (WPF Hosted Control )
-This HostedControl can be configured as a HostedApplication .. read the UII Development Guide for details
-First i would then add a TextBox for the searchstring and a button to start the search.
-In code behind (click handler for start button) kick off a thread which uses a HttpWebRequest (http://dotnet-snippets.de/snippet/simple-web-request-with-web-response/215) to send a request to your search websites .. for example search google for "FOOBAR":

https://www.google.com/search?as_q=FOOBAR 
Depending on the site to search there maybe exists a Webservice or some kind of api to search .. like the google search api ..

-Then the actual work begins .. parsing and aggregating the responses.. create a output on your Hosted Control...
Jun 19, 2013 at 6:18 AM
Hi Niklas,

I am really thankful for your help.

I am now getting the required details from web using Bing Api according to your instructions, but i have question regarding parsing of the data(as i don't have much idea) and show that in new tab which is a hosted control on click of a button.

Regards,
Jun 25, 2013 at 1:41 PM
Edited Jun 25, 2013 at 1:42 PM
Hi,

I havent worked with the Bing API so far but it sounds to me as if you already have your search results in some kind of object model. if thats the case, no further parsing is required.

Now you have to decide how you want the data to be displayed. It totally depends on your needs.

You could Display the content in your search control which would be the most easy way i guess. Just transform your Data in some kind of ViewModel and Bind it to .. lets say .. a datagrid. You also maybe would like to show the results in another tab in agentdesktop. Therefore you have to define a new dynamic HostedApplication via CRM. This application can then be created out of your hosted controll:
_uiiDesktop.CreateDynamicApplication(APPLICATIONNAME);
then you could pass the data to that application using a UII Action which you could fire out of your hosted control
FireRequestAction(new RequestActionEventArgs(APPLICATIONNAME, ACTIONNAME, YOURSEARCHRESULT));
something like that should do the trick. Focus on the Task of displaying your search results in a way i fits your needs. All other Tasks can easily be achieved using the UII Framework
Jun 25, 2013 at 2:31 PM
Hi,

I am getting the details as required and i have used datagrid to show the output as required through binding.Thanks for your help.

I was trying to inspect the UII Wpf Hosted Control, as i will be creating a workflow to get the data using context from CRM and then pass that to the inspected controls of the UII Wpf Hosted Control and execute the action for search. __I am not able to inspect the UII Wpf hosted control.__OR is there any other alternative to get the controls name so that i can use automation to pass the data from CRM.
Jun 25, 2013 at 7:52 PM
Edited Jun 25, 2013 at 7:53 PM
Well, i dont see a need for an automation here. All the tasks you've described can be done with plain c# code and the uii framework.

Just define an uii action at your hosted control via crm or via code (iam using a tablet right now, so I can't provide a exact code snippet for that). That action does not have to be a workflow...just choose "no automation".
Overwrite the DoAction method in your hosted control and check the parameter for your action name. If it hits, do your stuff. You are in your xamls code behind, so you just can access your textfields, trigger the buttons function or whatever.

I only use automations for third party apps or websites...

I am I missing something? I think you are almost done

Regards
Jun 28, 2013 at 10:53 AM
Hi,

Can we use UII Automation to compose a mail in the web application after signing in.

For e.g. :- There is a web application which has a signing in page, so it should take the username and password from CRM and then sign in, after signing in it is required to compose a mail. The process explained is needed to be done through automation in CCA and please guide me if there is any alternative.

Regards,
Jul 2, 2013 at 6:13 AM
ndi wrote:
Well, i dont see a need for an automation here. All the tasks you've described can be done with plain c# code and the uii framework.

Just define an uii action at your hosted control via crm or via code (iam using a tablet right now, so I can't provide a exact code snippet for that). That action does not have to be a workflow...just choose "no automation".
Overwrite the DoAction method in your hosted control and check the parameter for your action name. If it hits, do your stuff. You are in your xamls code behind, so you just can access your textfields, trigger the buttons function or whatever.

I only use automations for third party apps or websites...

I am I missing something? I think you are almost done

Regards
Hi,

Can you provide me the code snippet for the above mentioned solution.

Regards,
Jul 5, 2013 at 8:48 AM
Hi,

in the UII Constructor of your HostedControl add the following:
  if (actions != null )
                actions.Add("ACTIONNAME", new Microsoft.Uii.Csr.Action(actions.Count + 1, "ACTIONNAME", string.Empty));
after that you are able to handle the Action in the DoAction method of your hosted control
protected override void DoAction(RequestActionEventArgs args)
        {
           ...
            if (args.Action == "ACTIONNAME")
            {
               //here a miracle happens
.....