Export (0) Print
Expand All

Add Search Capability to a Form Using an IFRAME

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

This script will run when the Account form loads, and the name of the account is passed to Microsoft Live Search hosted in an IFRAME.

This sample is in the folder SDK\Client\HowTo\IFRAME.

To create the IFRAME

This code requires an IFRAME named IFRAME_SDK be added to the account form.

  1. Open Microsoft Dynamics CRM and navigate to Settings | Customization | Customize Entities
  2. Double-click the account entity in the grid.
  3. In the details pane, click Forms and Views.
  4. Double-click Form in the grid.
  5. In the Common Tasks pane, click Add a Tab.
  6. In the Add a Tab dialog box, enter Live Search in the Name box and then click OK.
  7. In the Common Tasks pane, click Add a Section.
  8. In the Add a Section dialog box, enter Live Search in the Name box and then click OK.
  9. In the Common Tasks pane, click Add an IFRAME.
  10. In the Add an IFRAME dialog box, the Name box will already have IFRAME_ as a prefix.  Add SDK after the prefix.
  11. For the URL, type www.live.com.
  12. On the Formatting tab, in the Row Layout area, check Automatically expand to use available space.
  13. Press OK to close the Add an IFRAME dialog box.

To add the OnLoad event script

Now we have to add code to the OnLoad event.

  1. With the Form dialog still open, click Form Properties in the Common Tasks pane.
  2. In the Form Properties dialog box, select OnLoad and then click the Edit button.
  3. Check the Event is enabled check box.
  4. Copy the JScript code below and paste it into the text box.
  5. Click OK to close the Event Details Properties dialog box.
  6. Click OK to close the Form Properties dialog box.
  7. Click Save and Close to close the Form dialog box.
  8. In the Forms and Views dialog box, select Actions | Publish from the actions menu.
  9. Click Save and Close to close the Forms and Views dialog box.

To test your work

  1. Navigate to Workplace | Accounts
  2. Open an existing account
  3. Verify the IFRAME used the account name in a Microsoft Live Search.

Example

This Jscript code passes the name of the account to the IFRAME.

var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;

var sLiveSearchURL = "";

if(IsOnline())
{
   switch (crmForm.FormType)
   {
      case CRM_FORM_TYPE_CREATE:
      
         // Point to the Microsoft Live Search home page when you create an account.
         liveSearchURL = "http://www.live.com";   
         break;

      case CRM_FORM_TYPE_UPDATE:
       
         // Use Live search with this account's name.
         liveSearchURL = "http://search.live.com/results.aspx?q=";
         
         // Encode the account name and add it to the search string.
         liveSearchURL += encodeURIComponent(crmForm.all.name.DataValue);
         
         break;
   }
}

// Set the IFRAME's URL.
crmForm.all.IFRAME_SDK.src = liveSearchURL;

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft