Dynamics CRM in the Field

Information from the Microsoft Dynamics CRM PFE team working in the field

Creating a Simple File Share in Microsoft Dynamics CRM 4.0

Creating a Simple File Share in Microsoft Dynamics CRM 4.0

  • Comments 5

Lately I have had some questions on how to display externally stored documents within CRM. and there are many ways to do this leveraging custom web pages or SharePoint document libraries. The options rely on other technologies and/or the creating custom code, so if you want a quick solution using minimal coding and without relying on other technologies, then using Windows Explorer is a good option.

In this scenario we are using a network share that contains folders for each of the accounts. To integrate this folder structure with CRM you can use an Iframe on the Account form that dynamically points to the correct account folder. For this example, we’ll use the exact account name for the folder name, but any other unique identifier could be used for the folder such as account number.

This solution assumes the folders have already been created on the network share and the names exactly match the account names. This can be taken a step further by using CRM plugins to automatically create the network share folders on the account create event.

Since we are using a network share this solution will not work over IFD.

Here is how to set it up.

1. Create a network share and populate it with some folders that match your account names. Permissions can be set on the share per company requirements.

clip_image002

2. Open the Account customizations and then the main account form within CRM.

3. Create a Documents Tab on the Account Form and add a section to that tab.

clip_image004

4. Create an Iframe on the Documents tab with the following properties and Click OK.

NAME: IFRAME_documents
URL: \_static\blank.htm
ROW LAYOUT (Formatting Tab): Automatically expand to use available space
clip_image006

clip_image008

5. Add JavaScript on the Form Load event to dynamically set the Iframe URL. The network share path needs to be updated to match your environment.

var CRM_FORM_TYPE_UPDATE = 2;

//Only Run code after record has been created.
switch (crmForm.FormType) {
    case CRM_FORM_TYPE_UPDATE:
    //Extract Account Name and add it to network path.
    var acctName = crmForm.all.name.DataValue;
    crmForm.all.IFRAME_document.src = 'file://crmsrv/customerdocuments/' + acctName;
}

6. Publish the Account form so the customizations take effect.

7. Now test to make sure the documents are displaying correctly. When you open the account form you will be able to see the related documents.

clip_image010

You can find more information regarding related services we provide here.

Development Workshop

Code Review

  • Very handy...

  • I tested this in CRM 2011 and it worked fine.  Thanks again!  Rayan

  • Is this working in IE8? In IE8 the "file://<network folder/" is opening in a new window.

  • So i set this up but i am getting an error can anyone help me figure out what wrong please?

    script used -

    crmForm.all.tab1Tab.style.display="none";

    var CRM_FORM_TYPE_UPDATE = 2;

    //Only Run code after record has been created.

    switch (crmForm.FormType) {

       case CRM_FORM_TYPE_UPDATE:

       //Extract Account Name and add it to network path.

       var acctName = crmForm.all.name.DataValue;

       crmForm.all.IFRAME_Customer_files.src = 'K:\CUSTOMER FILES\A\Andy Test Order/' + acctName;

    }

    error that came up -

    There was an error with this field’s customized event.

    Field: window

    Event:onload

    Error:Unable to set property ‘src’ of underdefined or null reference

  • @andrew:

    You should not use the crmForm if you use CRM 2011 (possible but not recommended) or 2013 (not possible any more). Instead use the Xrm.Page. ... to retrieve fields, formtypes, tabs, iframe sources, etc. The CRM SDK or the internet will give you a lot of hints how to work with it.

    Also I'm not sure if it will work with "k:\customer Files\A ...". If you have a look above you can see that JMorlok uses a file share like "file://server/...". I didn't try it but maybe this causes an error too.

    Thomas

Page 1 of 1 (5 items)
Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post