web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

SharePoint Document iframe on the form

(1) ShareShare
ReportReport
Posted on by 7,316

Hi,

I am trying to set up this implementation on a custom entity form following this article:

https://meghshyam.wordpress.com/2015/08/21/displaying-an-sharepoint-document-library-in-iframe-in-crm-2015/

I was able to set it up successfully but not quite what I wanted. I've setup to show the document upload control like the below screenshot.

81304.Capture.PNG

But instead, I am seeing this associated view of SharePoint Document like below:

3326.Capture1.PNG

This is the url I am using in the javascript web resource for setting iframe url.


https://XXXX/userdefined/areas.aspx?oId=FC02FEE6-AA17-E611-80ED-0050569C2FEF&oType=10027&pagemode=iframe&security=852023&tabSet=new_new_document_sharepointdocument&rof=false&inlineEdit=1

The other thing was, I did not see any relationship between my custom document entity and SharePoint Document entity after integrated SharePoint with CRM.. which I guess creates one automatically. So I created a 1:N relationship between my custom Document entity and SharePoint Document entity manually.

What am I doing wrong and why am I not seeing the iframe to upload documents like the first screenshot?

Please guide me through this. Thanks for any help.

*This post is locked for comments

I have the same question (0)
  • Inogic Profile Picture
    715 on at

    Hi meenoo,

    You may use the following code,

    1. First get the record id through the javascript,

    var recordId = Xrm.Page.data.entity.getId().replace("{", "").replace("}", ""); // Entity record Id

    2. Then get the entity type code,

    var oTypeCode = Xrm.Page.context.getQueryStringParameters().etc; //Entity Type code. Eg. for lead it is 4

    3. Then get the current form id,

    var CurrentFormId = Xrm.Page.ui.formSelector.getCurrentItem().getId().replace("{", "").replace("}", "");

    4. Now get the control of the iframe and set the src for the sharepoint document view,

    Xrm.Page.getControl("IFRAME_Documents").setSrc(Xrm.Page.context.getClientUrl() + "/userdefined/areas.aspx?formid=" + CurrentFormId + "&inlineEdit=1&navItemName=Documents&oId=%7b" + recordId + "%7d&oType=" + oTypeCode + "&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White"); // IFRAME_Documents is the name of the Iframe on the form.

    Thanks,

    Sam

  • meenoo Profile Picture
    7,316 on at

    Hi Inogic,

    It worked. I am able to see the upload iframe with all the buttons in it. But none of those buttons work. I mean whatever button I click.. I get 'Unexpected Error' message.

    The error says: Either Realm or TenantId for the organization 18f36748-ae6a-e411-9422-0050569c7679 must be non-null

    Why isn't it working? Please guide me.

    Thank you.

  • meenoo Profile Picture
    7,316 on at

    Another question I have is..

    The iframe that I get from the documents navigation bar show a different UI for iframe and the iframe that I inserted in the form through this scrip has different UI. Is it something that is related to the buttons that are not working for me?

    Navigation bar Iframe:

    0257.Capture1.PNG

    On the form Iframe:

    0257.Capture1.PNG

    Thanks.

  • meenoo Profile Picture
    7,316 on at

    Any suggestions please? Thx.

  • Craig Cross Profile Picture
    on at

    Hi!  I'm also trying to use the same type of approach and am running into the same issues.  Were you able to get this entire solution to work for you?  If so, please share the solution if you would.  :)  Many thanks!   Craig

  • Community Member Profile Picture
    on at

    Do you guys have any solution on the buttons not working?

  • meenoo Profile Picture
    7,316 on at

    Sorry guys.. I was never able to resolve this issue. I did all I can to make it work but couldn't. I took a completely different approach. If you guys happen to find any solution, I'd like to know.

    Thank you.

  • Community Member Profile Picture
    on at

    What was the different approach that you did?

  • Verified answer
    Community Member Profile Picture
    on at

    This script has worked for me in Dynamics 365 v8.2:

    function showInlineDocuments(context, iframeName) {

    const formType = context.getFormContext().ui.getFormType();
    switch (formType) {
    case 2://Update
    setIframeSrc(context, iframeName);
    toggleIframeVisibility(context, iframeName, true);
    break;
    default:
    toggleIframeVisibility(context, iframeName, false);
    return;
    }
    }

    function toggleIframeVisibility(context, iframeName, visible) {
    context.getFormContext().getControl(iframeName).setVisible(visible);
    }

    function setIframeSrc(context, iframeName) {
    const src = getIframeSrc(context);
    const iframe = context.getFormContext().getControl(iframeName);
    iframe.setSrc(src);
    }

    function getIframeSrc(context) {
    const formContext = context.getFormContext();
    const entityId = formContext.data.entity.getId().replace('{', '').replace('}', '');
    const etc = formContext.context.getQueryStringParameters().etc;
    const form = formContext.ui.formSelector.getCurrentItem() || formContext.ui.formSelector.items.get(0);
    const formId = form.getId().replace('{', '').replace('}', '');
    const src = formContext.context.getClientUrl() + '/userdefined/areas.aspx?formid=' + formId + '&inlineEdit=1&navItemName=Documents&oId=%7b' + entityId + '%7d&oType=' + etc
    + '&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White';
    return src;
    }

    To use it, call the showInlineDocuments function either when the form loads or when the appropriate tab is expanded. Make sure the 'pass execution context' option is selected in your event and include the control name as the iframeName parameter (e.g. 'IFRAME_documentsframe'). It's been tested in IE and chrome. I used the recommended settings and got the basic code here:

    https://jlattimer.blogspot.com/2017/01/show-sharepoint-documents-on-main-form.html

    Thanks.

  • Suggested answer
    Mohamed Bashir Profile Picture
    105 on at

    This is the code that I am using successfully to integrate the SharePoint Document Grid in an iframe.  I do have sharepoint server based integration enabled between CRM and SP.  I did add the SP url into the iframe property, and did add some additional code to hide this iframe from the mobile application.

    JS Code:

    function SetDocumentFrame() {

       var isCrmForMobile = (Xrm.Page.context.client.getClient() == "Mobile")

       if (isCrmForMobile) {

           // Code for CRM for phones and tablets only goes here.

       }

       else {

           // Code for web browser or CRM for Outlook only goes here.

           //Get Record ID through JavaScript

           var recordId = Xrm.Page.data.entity.getId().replace("{", "").replace("}", "");

           //Then get the entity type code,

           var oTypeCode = Xrm.Page.context.getQueryStringParameters().etc; //Entity Type code. Eg. for lead it is 4

           //Then get the current form id,

           var CurrentFormId = Xrm.Page.ui.formSelector.getCurrentItem().getId().replace("{", "").replace("}", "");

           //Now get the control of the iframe and set the src for the sharepoint document view,

           Xrm.Page.getControl("IFRAME_SharePoint").setSrc(Xrm.Page.context.getClientUrl() + "/userdefined/areas.aspx?formid=" + CurrentFormId + "&inlineEdit=1&navItemName=Documents&oId=%7b" +

           recordId + "%7d&oType=" + oTypeCode + "&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White");

       }

    }

    One important caveat is that this frame will not load with the document location until the record is created.  Because of this, I have the following JS as well:

    //hide the sharepoint tab until record creation

    function hideSharePoint() {

       var isCrmForMobile = (Xrm.Page.context.client.getClient() == "Mobile")

       if (isCrmForMobile) {

           // Code for CRM for phones and tablets only goes here.

       }

       else {

           // Code for web browser or CRM for Outlook only goes here.

           var formType = Xrm.Page.ui.getFormType();

           if (formType === 1) {

               window.parent.Xrm.Page.ui.tabs.get('tab_2').setVisible(false);

           }

           else {

               window.parent.Xrm.Page.ui.tabs.get('tab_2').setVisible(true);

           }

       }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans