Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

SharePoint Document iframe on the form

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

  • Suggested answer
    Vincent82 Profile Picture
    Vincent82 5 on at
    RE: SharePoint Document iframe on the form

    I found the supported way this can be done for the UCI... for online anyway.

    It can only be done through the make.powerapps.com website. (hens only online, as far as i know)

    https://make.powerapps.com/

    Login with a user from your CRM online enviroment, in the top right under enviroment select the CRM instance you want to edit.

    The on the right open 'solutions', then open the solution you want to added, navigate to the forum you want (search is in the top right).

    in the tree view (on the left), find the location you want to add the grid to.

    Then you can hit 'add component', add a subgrid, tick 'show related records' add and then find something like 'documents (regarding)' (atleast i think that's what it would be in english)

    save and publish (top right)

    If you now look at this grid in the old form editor much is grayed out (so it really isn't supported there), But you can make it take up more lines which is something i couldn't find how to do in make.powerapps.com.

  • Lee-Martin Profile Picture
    Lee-Martin 509 on at
    RE: SharePoint Document iframe on the form

    How do I get the Object type code out of a custom entity?

    I've tried using the ways suggested above, and the new methods to replace the depreciated methods.

    However it appears that either I can't retrieve this using those methods or my custom entity doesn't provide me with the object type code.

    Thanks

    Lee

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: SharePoint Document iframe on the form

    To solve this in UCI - follow this thread - www.crmug.com/.../viewthread

    Btw, this is unsupported approach - so we have to continuously monitor & fix whenever breaks :)

    Read my answer in Stack Overflow: stackoverflow.com/.../7920473

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SharePoint Document iframe on the form

    Did you get it working on 9.0 UCI?.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SharePoint Document iframe on the form

    Hi

    I got all to work so I have all the menu buttons which are also working and are refering to the correct SPdocuemntsite (if I click on "Open Sharepoint" I get to the correct site) BUT... I am not able to see the actual documents in the list. I suspect it has something to do with settings on Sharepoint for the site but haven´t been able to figure it out. Any ideas? 

  • rvprashanth Profile Picture
    rvprashanth on at
    RE: SharePoint Document iframe on the form

    This solution works on the classic interface. However it does not work on the new unified UI interface. Could you please suggest how this could work with unified app UI(v9.x) ?

  • Mohamed Bashir Profile Picture
    Mohamed Bashir 105 on at
    RE: SharePoint Document iframe on the form

    Set to fire on load.  We have since moved away from the mobile application, so my code has changed.  I did check it now, and I am not seeing the SP grid on the mobile app.  You may want to try the following:

    function SetDocumentFrame() {

       //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");

    }

    //hide the sharepoint tab until record creation

    function hideSharePoint() {

       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);

       }

    }

  • RE: SharePoint Document iframe on the form

    Hey Mohamed,

    We have the documents section working, but I'm having trouble hiding it from mobile.  I've used the mobile code to hide other things but it isn't working in this case.  Do you have the documents web resource firing on load or tab change?

    Thanks,

    Greg

  • Suggested answer
    Mohamed Bashir Profile Picture
    Mohamed Bashir 105 on at
    RE: SharePoint Document iframe on the form

    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);

           }

       }

    }

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SharePoint Document iframe on the form

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans