Programming4us
         
 
 
Applications Server

Extending Microsoft Dynamics CRM 4.0 : IFrames

8/15/2011 11:33:50 AM

Form Events

Two events are global in nature for all forms: the onLoad event and the onSave event.

The onLoad event fires after the form has completed loading, and is commonly used to send an alert to the user, disable fields, or modify field values.

The onSave event fires when the Save or Save and Close buttons are accessed, and it is important to note that it fires regardless of whether data on the form has been changed. This event is commonly used to validate an entry because the onSave event can cancel the save operation.

In addition to the form events, the onChange event is available for every field on a CRM form. To fire the onChange event, the field that has the event attached to it must have its value changed, and it must lose the focus (by the user selecting or tabbing elsewhere on the form).

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.

Note

Although this is one of the easiest ways to extend Microsoft Dynamics CRM, it does have one major limitation: You must have a connection to the underlying application. Therefore, if you’re working offline or remotely and your application requires a VPN to access (because it is on your local intranet), you should consider an alternative solution.

In addition, there is no built-in CRM reporting on any of the IFrame application data.


Note

Microsoft Dynamics CRM Online supports the creation of IFrames, but it doesn’t support the hosting of the underlying page. Therefore, you must leverage your own (or someone else’s) hosting services for an integration with CRM Online.


To create an IFrame, open the Form Designer, select Add an IFrame, and complete the information required. Figure 1 shows the basic information of a sample IFrame.

Figure 1. 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):

  1. typename

  2. type

  3. id

  4. orgname

  5. UserLCID

  6. 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 1 shows the object codes for CRM.

Table 1. Microsoft Dynamics CRM Object Type Codes
Account1Invoice1090
Activity134InvoiceDetail1091
AppointmentActivity142Lead4
EmailActivity138Opportunity3
FaxActivity136OpportunityProduct1083
LetterActivity141Organization1019
PhoneCallActivity137PriceLevel1022
TaskActivity134Product1024
ActivityParty135ProductPriceLevel1026
Annotation5Quote1084
BusinessUnit10QuoteDetail1085
Competitor123SalesOrder1088
Contact2SalesOrderDetail1089
CustomerAddress1071Subject129
Discount1013SystemUser8
DiscountType1080Territory2013
Incident112  

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 2 shows a GUID of a sample account in the address bar.

Figure 2. Microsoft Dynamics CRM GUID sample.

Note

Alternative methods of obtaining the GUID include adding a JavaScript onLoad event similar to "alert(document.location)" or a separate page that uses document.write to list out the query strings and their values.


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.

Note

As counterintuitive as it sounds, best practices usually call for using the entity name (for example, Account, Contact) rather than the type code. The reason for this is that entity codes may differ between one Microsoft Dynamics CRM installation and another.


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 1 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.

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.

Note

The restriction also applies to applications contained within the IFrame that may need to read from the CRM application.


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.

Note

The CRM Outlook laptop client has higher security restrictions in place, and in some cases it is not possible to programmatically update fields as described. Be sure to thoroughly test your solution in all environments before rolling out to production.

Other -----------------
- BizTalk 2009 : Using XML Namespaces (part 3) - Using System Property Schemas
- BizTalk 2009 : Using XML Namespaces (part 2) - Using Port Filters and Content-Based Routing
- BizTalk 2009 : Using XML Namespaces (part 1) - Understanding Property Promotions
- BizTalk 2009 : Understanding the Message Bus
- Active Directory Domain Services 2008 : Determine Global Catalog Servers
- BizTalk Server 2006 Operations : Disaster Recovery
- Configuring and Using Active Directory Rights Management Services
- Microsoft Dynamics GP 2010 : Installing the Dynamics GP 2010 application
- Microsoft Dynamics GP 2010 : Installing Microsoft SQL Server for Dynamics GP
- Starting a New BizTalk 2009 Project : BizTalk Naming Conventions
- Starting a New BizTalk 2009 Project : BizTalk Assembly Naming and Versioning
- Microsoft Dynamics AX 2009 : Working with Forms - Adding form splitters
- Microsoft Dynamics AX 2009 : Working with Forms - Building dynamic form
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 2) - Using Test-Driven Development & Creating a BizTalk Installation Package
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 1) - Five-Step Build Process
- Exchange Server 2010 : Manage Database Redundancy (part 3) - Manage Database Availability
- Exchange Server 2010 : Manage Database Redundancy (part 2) - Manage Database Replication
- Exchange Server 2010 : Manage Database Redundancy (part 1) - Configure Redundant Databases
- Extending Microsoft Dynamics CRM 4.0 : Customization Options by CRM Version & Customizing Navigation
- Extending Microsoft Dynamics CRM 4.0 : Limitations and Licensing Considerations
 
 
Most View
- iPhone 3D Programming : Vertices and Touch Points - Reading the Touchscreen
- Windows 7: Troubleshooting Networking - Troubleshooting Cables
- SharePoint 2010 : Start a Workflow
- Windows 7 : Using Dynamic DNS to Access Your Network & Configuring a Network Computer for Remote Administration
- Windows Server 2008 : Configuring Remote Access (part 5) - Virtual Private Networks
- Windows 7 : Customizing the Start Menu for Easier Program and Document Launching
- SQL Server 2008 : Profiler Usage Scenarios (part 2)
- SQL Server 2008: Administering Database Objects - Working with Tables (part 4) - Check Constraints
- SQL Server Integration Services : Connection Projects in Visual Studio
- SQL Server 2008 High Availability : Building Solutions with One or More HA Options
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS