I cant use ExecuteControlAction and SetControlValue doesnt work on Partylist

Aug 26, 2010 at 9:30 PM

FIRST PROBLEM

I have one new doubt. I am using a Workflow in CCA Everything is fine but I cant use the UII Activity executeControlAction and dont know why...  I can use SetControlValue, GetControlValue, Navigate, GetContext, but I used executeControlAction in a Button, in a tab and in a checkbox and this activity doesnt do anything...

if I try the same on HAT TestHarness, it executes the action.. . What I am missing in my workflow??
 

SECOND PROBLEM

On the other hand, when I use a SetControlValue on a Partylist it doesnt do anything and when I try it on HAT TestHarness, it deploys an error:
 
DataDrivenAdapterException (op=SetControlValue,controlName=SearchCustomer): DDA0108: Unsupported operation on control.

Do you know what I am missing in the first problem  and why is happening this in the second problem?

Aug 30, 2010 at 6:27 PM

Somebody can help me? Pleasee... Im stuck.

Aug 30, 2010 at 9:17 PM

On your first issue…

If everything else is working, but execute control action.. it sounds like HAT could not find the control… you might put a ControlFinder just before your execute and output the result to the tracelog to see if HAT sees it at that moment.  Consider though that Execute Control Action executes the Default behavior for any given HTML object… so for example. On a Textbox that’s “Focus”, whereas on a button, its “Click”.

On your second issue…

So the Short answer is that PartyList object on an activity is a special object in the CRM world, and is a customized object on the CRM Form… so standard HTML set / get stuff doesn’t really work well with it. This is something that is on the “to-do” list for a future release of UII/HAT. However that doesn’t help your current situation…

I would need to know a bit more about what your trying to do to provide substantive guidance… in a general sense however, there are 3 ways to deal with partylists.
1) Write a webapplication adapter talk to the control using MSHTML, which will let you talk to the Div / Lookup control.
2) Write an DDA extension for the web application adapter that does what I’m suggesting in 1
3) ( the most reliable and effective way ) use a Hidden Hosted control to create your activity and setup your partylists before you hand it into the visual space.

Insofar as difficulty, it really depends on your familiarity with the CRM SDK, #3 is the easiest in my mind, though at times less flexible then using HAT as your writing code to do it.

As I said this is something that is being looked into for the future for HAT as CRM has several controls like this.

 

Hope that helps.

MattB-MSFT

Aug 31, 2010 at 5:49 PM

Hi Matt Thanks.  on my first issue I used a ControlFinder before execute, and I see in the UII Debugger that it isnt recognizing it... Here is the debug:

In the Bindings is defined as a Button..

2010-08-31 10:26:37: UiiDebugger: Context = <UiiContext><CustomerFirstName>Rodolfo</CustomerFirstName><Email1>rodolfo@contoso.com</Email1><ZipCode>77432</ZipCode><State>Mexico</State><Phone2></Phone2><BillingAddress>Fundadores 5090
Mexico Mexico, 77432</BillingAddress><CustomerLastName>Paez</CustomerLastName><Phone1>982982982930</Phone1><CustomerName>Rodolfo Paez</CustomerName><IsNewCustomer>False</IsNewCustomer><AccountName></AccountName><CustomerType>contact</CustomerType><AccountID></AccountID><City>Mexico</City><CustomerID>c9b62b11-7d6a-df11-8b9b-00155d018007</CustomerID><Country>Mexico</Country><Street>Fundadores 5090</Street></UiiContext>
2010-08-31 10:27:06: IN DESKTOP CORE CALLING EXE DEFAULT ACTIONS IN DO WORKFLOW STARTED
2010-08-31 10:27:06: AutomationAdapter (session=5ca4eb62-79ba-4f7c-8b1b-8cd38adfbd38, app=Account or Contact): ContextChange(): context=<UiiContext><Street>Fundadores 5090</Street><CustomerFirstName>Rodolfo</CustomerFirstName><Email1>rodolfo@contoso.com</Email1><State>Mexico</State><Phone2></Phone2><BillingAddress>Fundadores 5090
Mexico Mexico, 77432</BillingAddress><CustomerLastName>Paez</CustomerLastName><CustomerName>Rodolfo Paez</CustomerName><ZipCode>77432</ZipCode><AccountName></AccountName><CustomerType>contact</CustomerType><AccountID></AccountID><City>Mexico</City><CustomerID>c9b62b11-7d6a-df11-8b9b-00155d018007</CustomerID><IsNewCustomer>False</IsNewCustomer><Country>Mexico</Country><Phone1>982982982930</Phone1></UiiContext>
2010-08-31 10:27:06: AutomationAdapter (session=ad5b9a8f-ceaa-484b-a8d2-f792edb9e58f, app=Case): ContextChange(): context=<UiiContext><Street>Fundadores 5090</Street><CustomerFirstName>Rodolfo</CustomerFirstName><Email1>rodolfo@contoso.com</Email1><State>Mexico</State><Phone2></Phone2><BillingAddress>Fundadores 5090
Mexico Mexico, 77432</BillingAddress><CustomerLastName>Paez</CustomerLastName><CustomerName>Rodolfo Paez</CustomerName><ZipCode>77432</ZipCode><AccountName></AccountName><CustomerType>contact</CustomerType><AccountID></AccountID><City>Mexico</City><CustomerID>c9b62b11-7d6a-df11-8b9b-00155d018007</CustomerID><IsNewCustomer>False</IsNewCustomer><Country>Mexico</Country><Phone1>982982982930</Phone1></UiiContext>
2010-08-31 10:27:06: AutomationAdapter (session=ad5b9a8f-ceaa-484b-a8d2-f792edb9e58f, app=KMI): ContextChange(): context=<UiiContext><Street>Fundadores 5090</Street><CustomerFirstName>Rodolfo</CustomerFirstName><Email1>rodolfo@contoso.com</Email1><State>Mexico</State><Phone2></Phone2><BillingAddress>Fundadores 5090
Mexico Mexico, 77432</BillingAddress><CustomerLastName>Paez</CustomerLastName><CustomerName>Rodolfo Paez</CustomerName><ZipCode>77432</ZipCode><AccountName></AccountName><CustomerType>contact</CustomerType><AccountID></AccountID><City>Mexico</City><CustomerID>c9b62b11-7d6a-df11-8b9b-00155d018007</CustomerID><IsNewCustomer>False</IsNewCustomer><Country>Mexico</Country><Phone1>982982982930</Phone1></UiiContext>
2010-08-31 10:27:06: UiiDebugger: Context = <UiiContext><Street>Fundadores 5090</Street><CustomerFirstName>Rodolfo</CustomerFirstName><Email1>rodolfo@contoso.com</Email1><State>Mexico</State><Phone2></Phone2><BillingAddress>Fundadores 5090
Mexico Mexico, 77432</BillingAddress><CustomerLastName>Paez</CustomerLastName><CustomerName>Rodolfo Paez</CustomerName><ZipCode>77432</ZipCode><AccountName></AccountName><CustomerType>contact</CustomerType><AccountID></AccountID><City>Mexico</City><CustomerID>c9b62b11-7d6a-df11-8b9b-00155d018007</CustomerID><IsNewCustomer>False</IsNewCustomer><Country>Mexico</Country><Phone1>982982982930</Phone1></UiiContext>
2010-08-31 10:27:06: WF/Automation e5f5c0f3-3c95-4b63-a613-817711e136e5 started: application=Case,action=default,data=,async=True
2010-08-31 10:27:06: WF/Automation 06a33453-d3e9-4af8-8e5c-0c3d11889c09 started: application=Case,action=registerContextChanged,data=,async=False
2010-08-31 10:27:06: WF/Automation 06a33453-d3e9-4af8-8e5c-0c3d11889c09 completed (duration 16ms): data=
2010-08-31 10:27:06: WF/Automation e5f5c0f3-3c95-4b63-a613-817711e136e5 completed (duration 125ms)
2010-08-31 10:27:08: WF/Automation 0b660ede-419a-484d-b484-0e302b3aa838 started: application=Case,action=default,data=,async=True
2010-08-31 10:27:08: WF/Automation 27828ff7-a3e6-4024-bf27-b5010ba8d9a5 started: application=Case,action=registerContextChanged,data=,async=False
2010-08-31 10:27:08: WF/Automation 27828ff7-a3e6-4024-bf27-b5010ba8d9a5 completed (duration 297ms): data=
2010-08-31 10:27:08: WF/Automation 0b660ede-419a-484d-b484-0e302b3aa838 completed (duration 531ms)
2010-08-31 10:27:30: WF/Automation deb192e0-4f49-46c5-915a-97172f4a8cfc started: application=KMI,action=Search KB,data=,async=True
2010-08-31 10:27:35: AutomationAdapter (app=KMI,action=__FindControl__): Posted implicit action exception: Microsoft.Uii.HostedApplicationToolkit.DataDrivenAdapter.DataDrivenAdapterException: DDA0304: Html element is not a <button/> element.
2010-08-31 10:27:35: WF/Automation deb192e0-4f49-46c5-915a-97172f4a8cfc exception: Microsoft.Uii.HostedApplicationToolkit.DataDrivenAdapter.DataDrivenAdapterException: DDA0304: Html element is not a <button/> element.
   at Microsoft.Uii.HostedApplicationToolkit.AutomationHosting.AutomationAdapter.AdapterFireActionFromAutomation(String applicationName, String actionName, Object data)
   at Microsoft.Uii.HostedApplicationToolkit.AutomationHosting.AutomationBridgeService.FindControl(String applicationName, String controlName)
   at Microsoft.Uii.HostedApplicationToolkit.Activity.ControlFinder.ExecuteImpl(ActivityExecutionContext context, AutomationBridgeService service)
   at Microsoft.Uii.HostedApplicationToolkit.Activity.HatActivityBase.Execute(ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
   at System.Workflow.Runtime.Scheduler.Run()
2010-08-31 10:27:35: WF/Automation deb192e0-4f49-46c5-915a-97172f4a8cfc terminated (duration 4609ms)

Aug 31, 2010 at 8:50 PM

Someone knows why is happening this?

Sep 1, 2010 at 4:13 PM
Edited Sep 1, 2010 at 4:17 PM

Can you post your bindings for the KMI application?  is the application CRM ? or somthing else?

MattB.

Sep 1, 2010 at 4:51 PM

Hi Matt! here is the XML of the KMI application, so you can use it with Hat test harness : )

<!--l version="1.0" encoding="utf-16-->

  
  
  
 
<?xml version="1.0" encoding="utf-16"?>
<initstring>
  <optimumSize x="0" y="0" />
  <minimumSize x="0" y="0" />
  <global />
  <displayGroup>
  </displayGroup>
  <adapter>
    <URL>Microsoft.Uii.HostedApplicationToolkit.AutomationHosting</URL>
    <type>Microsoft.Uii.HostedApplicationToolkit.AutomationHosting.AutomationAdapter</type>
  </adapter>
  <homePage useNewProcess="False">http://localhost:5555/CRMR2FULL/cs/dialogs/KBSearch.aspx?isLookup=true</homePage>
  <hostInside />
  <DataDrivenAdapterBindingsCollection>
    <DataDrivenAdapterBindings>
      <Type>Microsoft.Uii.HostedApplicationToolkit.DataDrivenAdapter.WebDataDrivenAdapter, Microsoft.Uii.HostedApplicationToolkit.DataDrivenAdapter</Type>
      <Controls>
        <ButtonElement name="SearchBtn" type="ButtonElement">
          <ElementMatchPath>/HTML/BODY/DIV/TABLE/TBODY/TR[1]/TD/DIV/DIV/TABLE/TBODY/TR/TD/TABLE/TBODY/TR/TD/FORM/TABLE/TBODY/TR[1]/TD/DIV/TABLE/TBODY/TR[3]/TD/BUTTON</ElementMatchPath>
        </ButtonElement>
        <InputElement name="SearchKB" type="InputElement">
          <ElementMatchPath>/HTML/BODY/DIV/TABLE/TBODY/TR[1]/TD/DIV/DIV/TABLE/TBODY/TR/TD/TABLE/TBODY/TR/TD/FORM/TABLE/TBODY/TR[1]/TD/DIV/TABLE/TBODY/TR/TD/DIV/INPUT</ElementMatchPath>
        </InputElement>
        <HtmlElement name="SelectedKB" type="HtmlElement">
          <ElementMatchPath>/HTML/BODY/DIV/TABLE/TBODY/TR[1]/TD/DIV/DIV/TABLE/TBODY/TR/TD/TABLE/TBODY/TR/TD[1]/TABLE/TBODY/TR/TD/DIV/TABLE[1]/TBODY/TR[1]/TD/DIV/TABLE/TBODY/TR/TD/DIV/TABLE/TBODY/TR/TD</ElementMatchPath>
        </HtmlElement>
      </Controls>
    </DataDrivenAdapterBindings>
  </DataDrivenAdapterBindingsCollection>
</initstring>

 

Sep 1, 2010 at 7:52 PM

Your path looks correct for CRM 4.
I would verify that the ExecuteControlAction shape is referencing the Control named “SearchBtn” with that exact case.

MattB-msft

Sep 1, 2010 at 9:50 PM

Hi Matt.. Here are some images from I verified  the ExecuteControlAction is referencing the same Control. .. Yo can see it..

 

Here are the images of my workflow, its code (I added one ifelse to see if the control is found or not by my code and didnt enter) and the UII Debugger just when it stops..

In the workflow, every step before execute and controlfinder is working.

 

Workflow. http://i54.tinypic.com/1674ks0.png

Code: http://i53.tinypic.com/20gms2g.png

UII Debugger: http://i56.tinypic.com/24wscv5.png

Sep 2, 2010 at 4:17 PM

Hrm.. that is odd, I built a quick test project here to simulate what your doing.. and it seems to work for me..
Can you shoot me a copy of your HAT project?

Mattb-MSFT

Sep 2, 2010 at 5:05 PM

Hi Matt.. thanks... I just sent you the project to your email..

Regards,

analaurette

Nov 21, 2012 at 7:57 PM

HI Matt!

If this new version of CCA this problem continue occurs. The stranger is that some machine works. I need to create a adapter with mshtml an then execute de click action.

Feb 12, 2013 at 7:01 PM
What I've found that works really well when integration CRM into CCA (since the controls are all in an IFRAME), is I've started using functions inside my CRM Forms that I call from CCA using MSHTML. I've found it to be faster than using the Automation pieces because I've been writing code for CRM for so long. I still leverage the automation's for CRM Ribbon buttons but for other more CRM code related things I use functions and MSHTML.

Jeremy
Feb 13, 2013 at 7:05 AM
Edited Feb 13, 2013 at 7:06 AM
hi jwinchell

nice approach - could you provide some code exsamples ??

tanks in advance
Feb 13, 2013 at 3:13 PM
NDI,

I can certainly do that. the code below is a function in my WebApplicationAdapter in CCA. The Adapter is hooked up to a Uii Web Hosted Control that displays the "Phone Call" entity in the tab of a customer session. This is opened in addition to the Customer and Incident from CRM, the Phone Call represents the incoming call received by the telephony system. The agent has a "Quick Action" list and when they select "Close Session" it triggers a couple of Actions, one of which is called "SetRegarding" and it's registered against my "Phone Call" tab. Essentially, this triggers some JScript in CRM to set the Regarding Field on the Phone Call = to the Active Incident being worked.


The JScript in CRM doesn't sit at the root of the HTML, it's actually inside a IFRAME in CRM called "contentIFRAME" which is the 1st IFRAME on the screen. Once we get a reference to that we can trigger any JScript functions we have in CRM on that Form.
private void SetRegarding(string data)
        {
            mshtml.HTMLDocument _doc = null;
            IHTMLWindow2 _win2 = null;
            mshtml.HTMLDocument _contentIFRAME = null;
            object _result = null;
            try
            {
                _doc = (mshtml.HTMLDocument)Browser.WebBrowser.Document;
                if (_doc != null)
                {
                    _win2 = (IHTMLWindow2)_doc.frames.item(0);
                    if (_win2 != null)
                    {
                        //_contentIFRAME = (mshtml.HTMLDocument)_win2.document;
                        _result = _win2.execScript("CCA_SetRegarding('" + data + "','incident','Current Request' );", "JScript");
                    }
                }
            }
            catch
            {
                //Do Nothing
            }
            finally
            {
                //Dispose Objects
                _result = null;
                 _contentIFRAME = null;
                 _win2 = null;
                _doc = null;
            }
        }
The code below is CRM specific code for setting a Regarding Lookup Field. This is based on the Phone Call Entity in CRM. A Lookup is nothing more than an array of objects.
//Set the Regarding Field on a Phone Call
//Triggered by Action in CCA
function CCA_SetRegarding(uniqueid,entitytype,name)
{
     var _obj = new Object();
     _obj.id = uniqueid;
     _obj.name = name;
     _obj.entityType = entitytype;

    var _lkup = new Array();
    _lkup[0] = _obj;
    Xrm.Page.getAttribute("regardingobjectid").setValue(_lkup);
}

function SetMultipleActivityParties(partyid1,partytype1,partyname1,party2id,party2name,party2type)
{
//Set Party 1
var _obj = new Object();
     _obj.id = partyid1;
     _obj.name = partyname1;
     _obj.entityType = partytype1;

//Set Party 2
var _obj2 = new Object();
     _obj2.id = party2id
     _obj2.name = party2name;
     _obj2.entityType = party2type;

    var _lkup = new Array();
    _lkup[0] = _obj;
    _lkup[1] = _obj2;
    Xrm.Page.getAttribute("to").setValue(_lkup);
}
Let me know if you have any questions or run into issues.

Jeremy
Feb 13, 2013 at 3:41 PM
Hey Jeremy,

thanks a lot for your fast reply! I've understood the concept and will transport it to our usecase - after that i will let you know if everything works as expected.

Nice, nice thanks again =)

Niklas
Aug 20, 2013 at 12:12 PM
Hi Analaurette,

How did you manage to get rid of the first problem, I am facing the same problem,

Please reply to https://crmcca.codeplex.com/discussions/453937

Thanks in advance,

Yatin Babaria
Jul 14, 2014 at 3:59 PM
I am trying to do the same thing for a Java Application. If I am trying to use the JavaDataDrivenAdapeter bindings, it is throwing me error telling that 'Couldn't recognise the DataDrivenAdapter type'.

As per MSDN.

"Java AWT applications are not fully supported in the HAT. You must configure the AWT applications with the WinDDA and run as regular Win 32 apps. The WinDDA uses Microsoft Active Accessibility (MSAA) to access the applications controls. Some AWT controls may not be fully compatible with MSAA and so may not function properly. The Java DDA is not supported for use with Windows Server 2008. To access Java AWT controls, you can use tools such as Java Ferret and Java Monkey."

Then, I used WinDDA instead of JavaDDA, but then if I execute for the particular control. It again throws me an error telling ' Control is unsupported'.

Infact, with Java application, I am not able to use any of functions - SetControlValue, GetControlValue, Navigate, GetContext.

Can anyone please suggest me if anyone have done any Java app automation with CCA?