CRM Contact and Account form within Agent desktop

May 17, 2010 at 2:52 PM


I was able to successfully install CCA and search for customer record within the Agent desktop. I am able to set the hosted application to open only one type of record either Contact or Account form.  Is there a way to do a set up to open account or contact form dynamically based on search results.

Example: I search for a customer Shawn and let us say I get two results 1. Shawn ( Contact record ) and Shawn & Co ( account record ). In the current situation I have set up the hosted application URL to contact form and when I need to open the account it throws an error. 

 Is there a way to set up both to open Shawn or Shawn and Co from my result?



May 17, 2010 at 10:11 PM

Yes, This is quite possible..

Though you would need to write some code to do it, developing a Web Adapter, or an Automation via the HAT tool kit to do it.

Unfortunately its not “simple” to explain, though I will take a go at it here…

Using HAT would be the easier approach to controlling the window shown.
Before you get started, you should read though the HAT section of the UII Developer guide, and take a look at a few of the HAT samples provided in the quickstarts directory.

What you’re going to want to do is setup a new HAT project, based on either the CRM Account or Contact,  in the default automation, you would register an event for the Notify Context changed event.
When the context changes, you need to determine if the you have an account or contact based on the Context Key “AccountID” ( you can see all the context key’s in the ContextVars file in the Samples.Common Project of CCA. If the “AccountID” is populated… then it’s Account, else is a Contact. If both are populated it’s a Contact that is linked to an account.

If it is an Account you want to raise an Action against your CRM window, let’s call it “ShowContact” , if it’s an Account, rais “ShowAccount”.. then publish your solution.

In UII Settings, for the hosted application you just published, look at the UII Actions, you will see a default action, it should be already setup with your HAT automation.. you will then need to add 2 actions, one for ShowContact and one for ShowAccount. Its easiest to use the URL Context Key Replacement technique to do it… there is a description of that here.

This seems like a good subject for a future blog post.. :)

May 18, 2010 at 7:26 AM

Hello MattB,

Thanks for your input, will try the suggested solution and let you know if any progress is made.



May 19, 2010 at 1:58 AM

see here:

May 20, 2010 at 5:44 AM

Thank you for the article. I will try the suggested solution.



May 27, 2010 at 8:14 AM

Hi ypitsch,

The url defined above gives me an 404 error.

Can you please explain a bit in detail about the example like what code needs to be written in the getcontext/code/navigate and how to trigger this in CRM  .I am new to this CCF and doing a bit of learning a detailed blog sample will be of some help moving forward and i appreciate your time.


Thx in Advance

May 31, 2010 at 4:00 PM

Hai MattB,

I fallowed your link it was very helpful to me but i was unable to work with both crm account and contact at a time from CustomerCareAgentdesktop

I fallowed these steps for this task,

  • Created HAT project (from Guidence packages UII Application Hosting Solution) 
  • Under applications folder i added HTML webapplication "customer" with application url about:blank
  •  Under automations i added a new project with "SequentialWorkflowLibrary" project then added following Activities
  • GETCONTEXT activity with context key "CustomerType" to get customertypecontextkey value from UII Context,
  • IFELSE activty to check "CustomerType" context key value from above activity is account or contact.
  • if it is account DOACTION activity with applicationname "customer" and actionname "showaccount"  else DOACTION activity with applicationame "customer" and actionname "showcontact"
  •  "customer" APPLICATION--> SET STARTUP AUTOMATION to DefaultAutomationProject
  • deployed to crm with "Deploy to server" option.
  • In Dynamics CRM under UII actions added 2 activities
  • showcontact url=http://servername:port/crm/sfa/conts/edit.aspx, querystring=%CustomerID
  • showcontact url=http://servername:port/crm/sfa/accts/edit.aspx, querystring=%CustomerID

I just getting blank page in place of account or contact

NOTE: I observed that with debuger  GETCONTEXT activity doesnot retrieve CustomerType context key value from UII CONTEXT and
from your explanation
i was unable to register an event for the NotifyContextChange event in the default automation, but i found only activty that RegisterActionforevent activity.

i was unable to code public override NotifyContextChange(Context context) method because workflow class not inherit from hostedapplication class.
so how should i get current UII CONTEXT?

can you guide me the way  to finish this task.


Thx in Advance


Jun 1, 2010 at 5:42 AM

My blog migration lost some posts. Here is the updated link


Aug 6, 2010 at 3:38 PM
My IAD was returning both Accounts and Contacts in the 'CustomerID' so I accomplished this with the 'CustomerType' field.
Aug 6, 2010 at 4:20 PM


I´m try to do this but when add a workflow assembly in the action not happening.

The workflow assembly is not loaded what ´s wrong?

The dll is the same directory of IAD.


In the UII Action form, i put in the worflow assembly type like this: [NAMESPACE].[CLASS],[DLL NAME]



Aug 11, 2010 at 2:38 PM

My problema above i solved!

Now  my problem is that i added two "DoAction" activities and put the aplication name and the actions(one for open contact and other to account, both inside de Hosted application that the workflow is running).

The workflow run but when "DoAction" is executed nothing happening.

The actioncs in the CRM is configured correctly.

Can anyone hel me?


Aug 11, 2010 at 3:45 PM

I do This for work correctly.

Update Default action, enabling the Automantion selecting by Workflow Assembly

  1. Create a Hosted Application
  2. Update Hosted Application, selecting Adpater by "Using Automation Adapter"
  3. Create a Project in VS2008
  4. Imported de the hosted control from server
  5. Create a Automation Project (Sequencial Workflow)
  6. Define the Default action to the sequencial workflow
  7. Publish to server
  8. In the Sequecial Workflow i do this
    1. Add GetContext activity for retrivie the CustomerID
    2. Add Another GetContext for retrivie the CustomerType
    3. Add IfElse
    4. In the IfElse activity verified thar the customer is an account
    5. Add two Code activites, one for true and other for false
    6. add two navigate activites, one for true and other for false
    7. In the class of the workflow i put two const with the url contact and account
    8. Add other two public varaibles of type string to recive the formated url;
    9. In the code activites i formated the url with the customerid to the public variables
    10. After this a bind the public variables to the url Property of each navigate Activity.
  9. After doing this i can open a contact or account, when is open a customer in the IAD.

Below is two picture show the Workflow and the Code Behind. - workflow - workflow code behind

Jun 2, 2011 at 5:22 PM


The url to navigate to Accounts/Contact page is hardcoded in the samples provided. Is it possible to access the application URL from initstring.

HAT however does not provide any way to do so.

Currently I am fetching this from configuration.

Thanks and Regards,


Jun 3, 2011 at 1:37 PM

From HAT, when using the document complete event, via Register for event, the URL that the page navigated to is passed into the automation. You can get it by using the GetActionData activity.