Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Has anyone been able to do this?

  • 1.  Has anyone been able to do this?

    Posted Apr 23, 2019 08:52 AM
    Edited by Simon Lester Apr 23, 2019 08:52 AM

    Issue opening a network file from CRM 365 online  (Version 9.1 April Update)

     

    We have a text field that you can double click and it opens a File on our internal network.

    This works in CRM 2011.  But it does not work in CRM 365. I've looked around the web and other are having the same issue. I've even tried changing the way it works to show a Web resource with a link to the file. But whatever I do I can't seem to open a file from CRM 365 in a new window.

    I've tried this in Chrome and IE11.

     

     

    function onLoad() {

        //debugger;

     

        // Function to open file by double clicking in the text field using the field value

        if (Xrm.Page.ui.getFormType() == 2) {

     

            if (Xrm.Page.getAttribute("colc_codsurveyform").getValue() != null) {

                alert("on control");

     

                window.parent.document.getElementById("colc_codsurveyform").style.color = "blue";

                window.parent.document.getElementById("colc_codsurveyform").style.textDecorationUnderline = true;

                window.parent.document.getElementById("colc_codsurveyform").ondblclick = function () {

                    var url = Xrm.Page.getAttribute("colc_codsurveyform").getValue();

                    if ((url != null) && (url.length > 0)) {

                        window.open(encodeURI("file:" + url));

                    }

     

                }

            }

        }

     

    }

     



    ------------------------------
    Simon Lester
    Business Application Developer
    City of London Corporation
    London, UK
    ------------------------------
    Conference-CRMUG_200x200


  • 2.  RE: Has anyone been able to do this?

    SILVER CONTRIBUTOR
    Posted Apr 23, 2019 09:30 AM
    Hi Simon,

    Does this work when you enter the result of '"file:" + url' directly in your browser?
    If yes, it is probably the browser security that prevent the link to be opened. You can try add your dynamics 365 url to the 'Local Intranet' security in your browser option to mimic what happened you you were on prem.

    ------------------------------
    Fabien Bernard
    CRM Developer
    Montréal QC
    ------------------------------

    Conference-CRMUG_200x200


  • 3.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 23, 2019 02:06 PM

    A couple of possible issues here, but I agree with Fabien's troubleshooting test of checking the URL directly in the browser to see if it will open.

    Another possible issue is that you are making  window.parent.document.getElementById calls in Dynamics.  This is a big no no as the DOM can frequently change in Dynamics, so there is no guarantee that you will get the same element each time. Using window.open is also a bad practice.

    If you want to use these, your idea of creating a custom HTML web resource with a large button that says OPEN SURVEY should work.  You can reference the record from the page, get the "colc_codsurveyform" value, and then use some JS or Jquery to get to the file.



    ------------------------------
    Chris Harrington
    Solutions Architect
    PowerObjects, an HCL Company
    ------------------------------

    Conference-CRMUG_200x200


  • 4.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 07:22 AM

    Chris

    Why is window.open considered bad practice? Especially since the native openEntityForm does not return a window id.

    Cheers! 



    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------

    Conference-CRMUG_200x200


  • 5.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 09:28 AM
    Rex,

    While you are correct that it does not provide an ID, using Window.open is not supported in Dynamics... so in general it's not a good idea to deploy it.  Plus it may or may not work in the newer UCI / Mobile clients correctly.

    MS provides methods to open dialogs, entity forms, URL's, and WebResources with these commands:

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation

    Certainly you can use Window.open if you want, but you run the risk of incompatibility issues.


    ------------------------------
    Chris Harrington
    Solutions Architect
    PowerObjects, an HCL Company
    ------------------------------

    Conference-CRMUG_200x200


  • 6.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 09:44 AM
    Chris

    Unfortunately, one needs the window id if one wants to execute functionalities on window events, such as closing. This is a common scenario when you update a child record that would affect the parent record and you want that change to be reflected on the parent form.

    I hope Microsoft would add this CRUCIAL data in the future.

    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------

    Conference-CRMUG_200x200


  • 7.  RE: Has anyone been able to do this?

    Posted Apr 29, 2019 04:52 AM
    ​Thanks for all the responses. We've accepted that it's not the right way to do it and are now using SharePoint for the documents. We were not so keen on doing that partly because it meant a change in process for the users in question but they like it!

    Thanks again for the advice

    Simon

    ------------------------------
    Simon Lester
    Business Application Developer
    City of London Corporation
    London
    ------------------------------

    Conference-CRMUG_200x200


  • 8.  RE: Has anyone been able to do this?

    SILVER CONTRIBUTOR
    Posted Apr 24, 2019 04:43 AM
    Hi,
    I think you are correct that this doesn't work.  I remember looking into it a while back and no amount of JavaScript wizardry was going to get round the security that Microsoft put into D365CE Online.  I recall that our options were - create an ASPX page that acted as a proxy for the internal file system or move the files to SharePoint.

    ------------------------------
    Andrew Wolfe
    Head of CRM Practice
    Technology Services Group
    United Kingdom
    ------------------------------

    Conference-CRMUG_200x200


  • 9.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 03:16 AM
    Is the requirement that users on the network can access local files by clicking a link from the CRM?
    Make the local server a web server and the files should be accessible once users are on the network.

    See https://www.devside.net/wamp-server/accessing-websites-on-a-local-network-lan-web-server

    You will have to update the way the links are added and so on but this should work.

    ------------------------------
    Donal McCarthy
    BrightWork
    Galway
    ------------------------------

    Conference-CRMUG_200x200


  • 10.  RE: Has anyone been able to do this?

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 07:37 AM
    Edited by Rex Kenley Tan Apr 25, 2019 07:37 AM
    Simon

    I would suggest using sharepoint or blob storage. But you can also create a simple nodejs express api that would stream your requested file through a web api. I created one to display pdf files in crm365.

    https://expressjs.com/en/starter/static-files.html

    Cheers!

    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------

    Conference-CRMUG_200x200


If you've found this thread useful, dive deeper into User Group community content by role