IFrames
One of the easiest ways to perform an integration to an existing Microsoft Dynamics CRM deployment (both hosted or On Premise) is to use IFrames.
IFrames are "inline frames or windowless inline floating frames" and provide an easy mechanism for integrating data, because they can exist free form or easily pass data through them to the underlying source.
To create an IFrame, open the Form Designer, select Add an IFrame, and complete the information required. Figure 3.7 shows the basic information of a sample IFrame.
Figure 3.7 Microsoft Dynamics CRM IFrame creation example.
You want to pay special attention to two areas:
- Pass Record Object-Type Code and Unique Identifier as Parameters
- Restrict Cross-Frame Scripting
The first option (Pass Record Object-Type Code and Unique Identifier as Parameters) is actually six parameters in Microsoft Dynamics CRM 4.0 (only two in the previous version):
- typename
- type
- id
- orgname
- UserLCID
- OrgLCID
The typename is the name of the entity (Account, Contact, and so on). For custom entities, the customization prefix is prepended (normally new_; but if you've changed the customization prefix, which is always a good practice, that will be your prefix, followed by the entity name. For example, if we create a new entity called ProjectDescriptions, the typename will equal new_ProjectDescriptions or wf_ProjectDescriptions).
The type is an integer that uniquely identifies the entity. Table 3.2 shows the object codes for CRM.
Table 3.2. Microsoft Dynamics CRM Object Type Codes
Account |
1 |
Invoice |
1090 |
Activity |
134 |
InvoiceDetail |
1091 |
AppointmentActivity |
142 |
Lead |
4 |
EmailActivity |
138 |
Opportunity |
3 |
FaxActivity |
136 |
OpportunityProduct |
1083 |
LetterActivity |
141 |
Organization |
1019 |
PhoneCallActivity |
137 |
PriceLevel |
1022 |
TaskActivity |
134 |
Product |
1024 |
ActivityParty |
135 |
ProductPriceLevel |
1026 |
Annotation |
5 |
Quote |
1084 |
BusinessUnit |
10 |
QuoteDetail |
1085 |
Competitor |
123 |
SalesOrder |
1088 |
Contact |
2 |
SalesOrderDetail |
1089 |
CustomerAddress |
1071 |
Subject |
129 |
Discount |
1013 |
SystemUser |
8 |
DiscountType |
1080 |
Territory |
2013 |
Incident |
112 |
The id is the ObjectId, which is the unique identifier or GUID. This value is displayed in the URL of every form in the system (and is null until the form is created).
Figure 3.8 shows a GUID of a sample account in the address bar.
Figure 3.8 Microsoft Dynamics CRM GUID sample.
The orgname is the unique name of the organization, the UserLCID is the language code in use by the current user, and the OrgLCID is the language code that represents the base language for the organization.
Both the UserLCID and the OrgLCID are four-digit codes. For a complete reference of language codes, see Appendix A, "Locale ID (LCID)."
Consider this illustration of the effect that passing these parameters has. When the URL referenced in Figure 3.7 is called without Pass Record Object-Type Code and Unique Identifier as Parameters being selected, the following URL is called from the form:
http://www.webfortis.com/clientportal.aspx
When the Pass Record Parameters option is selected, the following URL is called from the form:
http://www.webfortis.com/clientportal.aspx?type=1&typename=account&id={5CA8FBFF- 46E9-DC11-914C-0030485C8E55}&orgname=Webfortis&userlcid=1033&orglcid=1033
The page that is being displayed in the IFrame (in this case, the clientportal.aspx) can easily read the variables using the HttpRequest.QueryString. (If you are using an HTM page, the parameters can be accessing using the window.location.search property in JavaScript.)
Table 3.2 shows the object codes for CRM.
You can readily see how powerful and easy it is to create specific information related to the selected record on the underlying application using this information.
For an example of how this data is referenced in an application, see the last example in this chapter and see Chapter 5, "SharePoint Integration."
The second option, Restrict Cross-Frame Scripting, is selected by default to help protect the integrity of the CRM application. The effect of this selection is to basically place the application in the IFrame in restricted mode (as defined in Internet Explorer).
This option is unselected when you want to have a level of interaction between the application that is in the IFrame and CRM.
An example of this is a custom application that performs a background check on an account for credit-worthiness. When the credit check comes back, the custom application could reference a Boolean value on the account form and set the value of Background Check Cleared equal to true.
For more information about IFrames, be sure to thoroughly review the IFrame documentation on MSDN at http://msdn2.microsoft.com/en-us/library/ms535258.aspx.
We've included an example of how an underlying application might work using an IFrame with parameters; see the third example in the Examples section of this chapter.