Friday, September 14, 2012

Cross domain access from Silverlight

Silverlight control hosted at http://myserver/mypage.aspx can access only services on that same domain by default – for example http://myserver/service.svc, but not a service at http://otherserver/service.svc. This prevents a malicious Silverlight control hosted on the http://myserver domain from calling unauthorized operations on a service hosted on the http://otherserver domain.

To enable a Silverlight control to access a service in another domain, the service must explicitly opt-in to allow cross-domain access. By opting-in, a service states that the operations it exposes can safely be invoked by a Silverlight control, without potentially damaging consequences to the data that the service stores.

To allow cross domain access place clientaccesspolicy.xml and crossdomain.xml file at the root of the domain where the service is hosted. In the above example the file will be placed at the http://otherserver.
 
Create a clientaccesspolicy.xml file to allow the access from any other domain to service of the current domain.
 
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
 
There are three types of wildcards allowed:
 
1.      <domain uri=”*”/>:This option is used to allow access to all domains of the same scheme. An HTTP service will allow all HTTP callers. An HTTPS service will allow all HTTPS callers.
 
2.      <domain uri=”http://*”/> or <domain uri=”https://*”/>:The first option is used to allow access to HTTP service from HTTP callers and HTTPS service from HTTP callers. The second option is used to allow access to HTTP service from HTTPS callers and HTTPS service from HTTPS callers.
 
3.       <domain uri=”http://*.myserver.com”/>(subdomain):This option uses a wildcard at the first segment of the path ("http://*.contoso.com", for example) that allows all subdomains of the domain specified. So for the example.http://web.myserver.com would be allowed. Note that a uri path where the wildcard does not occur as a prefix (http://web.*.com, for example) is disallowed.
 
To prevent malicious attacks, you should never provide one client access policy file for both HTTP and HTTPS services on your domain that enable calls from both HTTP and HTTPS clients.
 
To allow access to specific domain, you need specify the particular uri e.g. <domain uri=”http://otherserver.com”/>. So http://myserver/service.svc service will be accessible from only http://otherserver.com (other domain).

You can implicitly deny access for all domains not listed in a <domain> element tag in a Silverlight policy file.

Create a crossdomain.xml file that contains the following configuration. The file must be configured to allow access to the service from any other domain, or it is not recognized by Silverlight 4.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
 

Monday, September 10, 2012

Phone Formating in SSRS report


Many a times there had been requirements to format the CRM phone number in the SSRS report in following format.


We tried to achieve this by creating 12 text boxes and in each textbox we applied the below logic in the expression.

= IIF(Fields!telephone1.Value.toString().Length>=1, GetChar(Fields!telephone1.Value.toString(),1), “”)

It works successfully when the length of phone number is equal to 10. But it fails when the length of phone number is less than 10 and you will get an error while running this report.

To resolve this issue we found a work around for this.

First you need to format the data using the SQL query and PAD the spaces into the field. As given below.

LEFT(ISNULL(telephone1, '') + '          ', 10)

The above statement will format the telephone1 attribute. If the user enters errorneuos or junk data into the telephone1 field like “99”, then the above statement will return the value “99        ”, i.e. 99 + additional 8 spaces . And in the textboxes expressions you just need to write the following expressions without checking the IIF condition.

= GetChar(Fields!telephone1.Value.toString(),1)
= GetChar(Fields!telephone1.Value.toString(),2)
= GetChar(Fields!telephone1.Value.toString(),3)
= GetChar(Fields!telephone1.Value.toString(),4)


Hope this helps!
 

Monday, August 6, 2012

Tips to Install CCA for CRM 2011

The Customer Care Accelerator for Microsoft Dynamics CRM 2011 delivers contacts center functionality. The CCA for Microsoft Dynamics CRM will work with all deployment models for including on-premise and Microsoft Dynamics CRM Online.

You can follow below Steps to Install CCA:

1.       To install CCA you need to download the setup from Microsoft Marketplace. The installation package contains source code, binaries, customizations, and documentation.
2.       Unzip the downloaded file. It contains an Accelerator folder (CCA setup files) and a UII folder (the UII framework install files). You also get a couple deployment guides.

3.       From the UII folder run the executable file (32 bit or 64 bit). It is a simple installation process. While installing you will be asked to specify the organisation name where you intend install CCA. Please refer below screen. Specify the Organization Name and proceed with complete package install to use all features of CCA.


 4.       Now from the Accelerator folder run the 32 or 64 bit executable file. This will unzip few more files into the install folder. After this run, the “Microsoft UII” folder will contain all the source code and other files which are required to proceed with the further steps.
5.       In next step you need to import some solution files in CRM. Import the two solution files listed in below screen shot:
           a)      Import the solution “UiiForMicrosoftDynamicsCRM2011_1_0_managed.zip” from the location specified below:


b)      Import another solution “ReferenceImplementationforUII_1_0_managed.zip” from the location specified below.

 
  6)       After importing the above managed solution you need import below specified data files which you need to map with “UII Hosted Applications” entity as shown in below screen.
(Note: Please make sure that you have installed standard Sample Data in your CRM. Go to Settings -> Data Management -> Sample Data and install sample data into your system)

 

 While Importing these files you need to fix the 2 field mapping errors before you process the files which are listed below:


 Map the Above fields to their associated field and proceed with import.
7)      Next Step is to generate “RIConfigLoader” application. For this you need to follow the instructions from the UII Deployment Guide to Install UII Component.
8)      Open the “Microsoft.Crm.Accelerator.Cca.AgentDesktop.sln” solution file and build the solution.


To resolve this issue you need to download the “Microsoft.Practices.CompositeUI.Windows.dll”, add reference to the project and build the solution. This will generate the “RIConfigLoader“ application. Run the application shown in below screen shot.



9)      Once you run this, you will get the below screen to connect with CRM.


Provide the connection details required to connect to CRM. To get the CRM Service URL Go to Settings -> Customizations -> Developers Resources. Look for the Discovery Service URL. When the connection is successful you need to select CRM Organization and click on “Deploy” as shown in below screen.


10)      Go to the location where Agent Desktop’s “config” file is located and open it in Notepad. We only need to change the Organization Service URL and Authentication Mode in the “AgentDesktop.exe.config” file as shown in below screen shot.


11)      Run the Agent Desktop Application.



12)      You will get the pop up of CCA Agent Desktop screen as below.


13)      When you click the Case it will automatically navigate to the Customer i.e. Account page. You can also find the Task explorer where you can select workflow list from which you can initiate a CCA workflow as shown in below screen shot.


14)      When you select “Service Case By Phone” and follow the steps you will get the below screen to Dial a Number on the step of Call Customer.


15)      After this you can add your notes in the Text Box to update Notes in the Selected Case. Please see below screen shot.


Sunday, July 29, 2012

How to get all the selected records id for the bulk edit form

Further to one of our previous blog spot

We can write scripts on bulk edit form to check that the entered field value is unique for the selected group of records. If the value is duplicate then the user should get an alert and the bulk edit form should be closed.

To achieve this, we need to retrieve all the records and compare the new value with the existing values.

But to retrieve we require the ids of all the selected records for bulk edit. To get ID we normally use

Xrm.Page.data.entity.getId()

But this will not give us the id of all the selected records. To get ids of all selected records we need to use a window command window.dialogArguments.

 //check whether the form is bulk edit form

 var formType = Xrm.Page.ui.getFormType();

if (formType == 6)
{

 //Read ids from dialog arguments

 var records = window.dialogArguments;

 for(i=0; i<records.lenght;i++)
 {
   alert(records[i]);
 }
}

Hope this helps and is useful!!

Friday, July 20, 2012

Outlook Authentication issue fixed in Rollup 8

We have noticed this with the Online and IFD environment, that, if you are using "CRM 2011 Outlook Client" and try to open any web resource like html file and Silverlight application (.xap file) or any entity record using window.Open() or Response.Redirect() then you get prompt for user name and password.

Window.Open() methods opens the CRM record in the browser (IE) and outlook does not pass your CRM credential. As you are not logged-in in the CRM from browser (IE), it asks credentials of user.

If you are already logged-in from browser and open CRM record from Outlook client then it will not prompt for the user credential.

Microsoft has released Rollup 8 which exposes two new methods through SDK. These methods will open window in the process Outlook.exe instead of Iexplore.exe. So it will not ask for credentials.

Below are two methods:
 
     1)  openWebResource(string webResourceName, string webResourceData, int width, int height):

This opens a HTML web resource page.

             i.   webResourceName: This is the name of the web resource that you want to open.
             ii.  webResourceData: Parameter that is to passed to the web resource. Web page (HTML) or Silverlight Web resource page can only accept a single custom parameter called data.
              iii. width: Width of the window
              iv.  height: Height of the window.
 e.g. Xrm.Utility.openWebResource("new_/pages/test.html",null,700,700);
 
 
     2)  openEntityForm(string name, string id, Dictionary parameters):
This opens an entity form dialog e.g. Account record.
 
                  i.            name: Name of the entity of which record is to be opened. e.g. account.
                  ii.           id: GUID of the record. e.g. "89A2F3FB-18FF-E011-A003-00155D005515".
                  iii.          parameters: Parameter that is to passed to the record. 
e.g. Xrm.Utility.openEntityForm("account","89A2F3FB-18FF-E011-A003-00155D005515",null)