locked
IFrame & EasyXmd RRS feed

  • Question

  • Consider the following scenario. The Account entity is customized with an IFrame. The IFrame is showing data that is pulled from Web Services from another domain. The Web Service requires the account ID. So basically, when I open an account record:

    1) The IFrame aspx page is asking for the account ID (note that the aspx page is on a different domain than CRM)
    2) The page showing the account record (basically CRM) is responding with the account ID to the IFrame.
    3) Now the external app is retrieving additional information from the 3rd party database and displays it in the account entity

    The issue with this approach is that I need to communicate across domains to get the information into the IFrame. It seems EasyXmd can solve that problem. However, any attempt over the last week or so failed. The documentation I found is inconsistent. Is there some example how I can use this with Dynamics CRM, i.e. communicate between a particular record and its equivalent in the external DB?

    Thanks in advance for any input.

    Saturday, May 17, 2014 6:21 AM

All replies

  • hfaun, please make sure below points when you work with Iframe into any Entity form and Iframe use CRM Entity record as input:-

    1) When you insert iframe into Account form, make sure option "Restrict cross-frame scripting, where supported" is uncheck

    2) when you insert Iframe into Account Form, make sure option "Pass Record object-type code and unique identifier as parameters." is checked.

    3) These above 2 option will enable Account record values into querystring into your external application URL. you need to take the values from your external Application code behind to process those query string values like below..

    If Not String.IsNullOrEmpty(Request.QueryString("id")) Then
                    strEntityGUID = Request.QueryString("id").Replace("{", "").Replace("}", "").Trim
                    If Not String.IsNullOrEmpty(Request.QueryString("type")) Then
                        strEntityTypeCode = Request.QueryString("type").ToString
                    End If
                End If

    4) Also when you create new Account, this iframe will not have any values into your External Application URL, so handle that scenario into your code behind to not load any thing or how ever you want.

    Le me know if this helps or not.

    Saturday, May 17, 2014 11:57 PM
  • Nicksoft2011, thanks for the answer. I already did 1) and 2). I can get the ID of the account record without any issues. However, I need to get another field from the account record so I know what data to pull up from the external data source. I could implement single sign on to access CRM and load the account data to get this field. However, this seems complicated. I have never done single sign on. In addition I can imagine it might not work for deployments that do not use IFD, hence I would have to implement two paths, one with IFD and one without IFD.

    Consdering the above, I simply want to access an account field from my IFrame. If the code for my IFrame is on the same subdomain as CRM that's pretty easy. However, I need to get a field on the site that is hosting my IFrame and that IFrame is on a different domain.

    Sunday, May 18, 2014 1:08 AM
  • You could:

    1. Pass the Account ID (the field you pass to the web service) on the querystring of the page in the IFrame. Use javascript in the OnLoad event of the CRM form to read the Account ID value, create the url, and set it on the IFrame using the setSrc method
    2. The page in the IFrame can then read the query string from window.location

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, May 19, 2014 1:32 PM
    Moderator
  • David, it seems that this only allows a one-time communication, i.e. at the beginning when the IFrame is loaded. Having said that, it's actually all I need at this point so this approach should work fine. I am running in some troubles, though. According to MSDN the OnReadyStateComplete event should be used.

    "Then use a Field OnChange Event, IFRAME OnReadyStateComplete Event, or Tab TabStateChange Event and the setSrc method to append your parameters to the src property of the IFRAME or web resource.... Avoid using the OnLoad Event. IFRAMES and web resources load asynchronously and the frame may not have finished loading before the Onload event script finishes. This can cause the src property of the IFRAME or web resource you have changed to be overwritten by the default value of the IFRAME or web resource URL property."

    So I did implement this on the OnReadyStateComplete but that creates an infinite loop. It seems like using the setSrc event makes the IFrame load again and with that trigger the OnReadyStateComplete again resulting in an infinite loop. I could check if it was loaded before and set a flag but then I could not distinguish between a valid reload and that infinite loop.

    Tuesday, May 20, 2014 5:27 AM
  • You should be able to set the IFrame source to about:blank in the form definition, then in the OnReadyStateComplete event check the url, and only if it is about:blank then change it using setSrc


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, May 20, 2014 12:40 PM
    Moderator
  • David, thanks. I tried this but now OnReadyStateComplete does not fire at all. I created a new thread as it seems unrelated to this issue but if you have any suggestions I certainly would appreciate it. Btw, I disabled/enabled the function, rebooted, installed rollup 16, cleared the cash/history/etc from IE and other trials, all without success. The OnLoad event triggers just fine and calls the function but due to the comment from MS I think I really should put it in OnReadyStateComplete.
    Tuesday, May 20, 2014 8:32 PM
  • It turns out that OnReadyStateComplete does not fire because the URL for the IFrame is set to about:blank. If I set it to any other website the event fires. When I set it back to about:blank it stops firing. So this approach does not seem to work. I could use the OnLoad event IF I know for sure that the race condition MS mentioned will never occur, i.e. the IFrame, which loads asynchronously, will never have the URL I set in OnLoad overwritten by the default URL about:blank. Considering that nothing is loaded in the IFrame this MIGHT be a reasonable assumption but is this indeed the case?
    Thursday, May 29, 2014 4:09 AM