06 May 2009

CRM 4.0 IFrame: Show Advanced Find Result View

There are many people asked about: How to show the Advanced Find result view in an IFrame? Instead of building a custom aspx page(dynamically passing parameters, see Adi's solution), I have another method to share if you don't need passing parameters into the query.

1. Build your Advanced Find query and save it, then copy the Shortcut.



2. Put a IFrame control on the Form, clear the "Restrict cross-frame scripting" checkbox.



3. Put the below code to the OnLoad() event, you need to change the IFRAME_view name and the iFrame.src (copy and paste from the step 1)



var iFrame = crmForm.all.IFRAME_view;

iFrame.src = SERVER_URL + "/advancedfind/advfind.aspx?etn=contact&QueryId=%7b3882F0FA-2B3A-DE11-BFB8-0018FE7F3A64%7d&ViewType=4230&AutoRun=True";
iFrame.attachEvent( "onreadystatechange" , Ready);

function Ready()
{
var iDoc = iFrame.contentWindow.document;
if(iDoc.getElementById("crmMenuBar") != null && iDoc.getElementById("btnBack") != null)
{
iDoc.getElementById("crmMenuBar").style.display = "none"; // hide the top menu bar
iDoc.getElementById("btnBack").style.display = "none"; // hide the bottom BACK button
}
}


14 comments:

  1. I was curious to what kind of AF you were using? I have a custom entity of "Machines" that each customer has. Can I use this to see which machines match each Shipping Address in CRM?

    ReplyDelete
  2. Very nice, but don't forget to share the advanced find.. else you will get an error

    ReplyDelete
  3. To Sander: as soon as you can get the result through CRM Advanced Find and save it as a view, you can use this technique to show the result view.

    ReplyDelete
  4. To vandelden: cheers indeed!

    ReplyDelete
  5. Jim, i created a team for all advanced finds on forms and added all users to this team.
    (extra tip).

    ReplyDelete
  6. Another Issue.
    It is not possible to use this feature twice on one form.

    ReplyDelete
  7. I created an Advance view for contract line which i would like to display in an Iframe under a custom tab. I can't seem to get it to work using your example.
    I have shared the view with everyone. The source works if used in the web browser. It came to work inside the IFrame.
    I have crm4.0, rollup 5 installed.
    Any suggestions

    ReplyDelete
  8. Thanks for your great post. You've been always helpful.

    A short question, how did you disable the menu bar? I am refering to the one where it says "New" "Delete" etc.

    Thanks.

    ReplyDelete
  9. This is extremly useful, but I can't seem to get the content displayed in the iframe to dynamically change based on the account name. I would like to display all the PT products which share the same main account i.e xxxx.

    I've created an advanced find for the custom entity (PT products) where the main account = xxxx, but the iframe shows the same info regardless of the account name.

    How can I get the advanvced find to reference the account field without specifying the account name (xxxx)? script is as follows:

    var iFrame = crmForm.all.IFRAME_ptproducts;

    iFrame.src = "/" + ORG_UNIQUE_NAME + "/advancedfind/advfind.aspx?etn=new_software&QueryId=%7bCDED1592-F35B-DE11-B51B-0019B9F9C0EA%7d&ViewType=4230&AutoRun=True ";
    iFrame.attachEvent( "onreadystatechange" , Ready);

    function Ready()
    {
    var iDoc = iFrame.contentWindow.document;
    if(iDoc.getElementById("crmMenuBar") != null && iDoc.getElementById("btnBack") != null)
    {
    iDoc.getElementById("crmMenuBar").style.display = "none"; // hide the top menu bar
    iDoc.getElementById("btnBack").style.display = "none"; // hide the bottom BACK button
    }
    }

    ReplyDelete
  10. For some reason, the check box "restrict cross frame scripting" is gray out and cannot be unchecked.
    Is this a customization issue? how can unchecked it?

    ReplyDelete
  11. hi
    Ca we use this code for CRM 2011 .

    I am not finding any option like "COPYShortcut" in Advanced Fined View.

    ReplyDelete
  12. Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. ERP Software in Mumbai || System Software || CRM Software in Mumbai || MLM Software

    ReplyDelete
  13. Dich vu ke toan ACB chuyên cung cấp dịch vụ kế toán trọn gói uy tín chuyên nghiêp giá rẻ nhất tại HCM và các tỉnh lân cận với chi phí bỏ ra chỉ từ 500.000-1.500.000đ.
    Liên hệ: Dich vu ke toan , Dịch vụ kế toán.
    Lầu 4, Tòa nhà Long Mã, 602 Cộng Hòa,P.13,Q.Tân Bình,HCM.
    Hotline: (08) 62 97 97 97 - 0966 660 888.

    ReplyDelete