locked
Open Folder via javascript RRS feed

  • Question

  • Hi,

    I need the following functionality:

    the user will register the path to a network folder (ex: \\ server01\example) then click to save it if this field should open this folder.

    someone help me?

    Thank

    Luiz Henroqie
    Tuesday, April 28, 2009 1:22 PM

Answers

  • We have accomplished this in 2 ways:  the first is allowing the user to doubleclick on the field to open the folder and the second is to add a button to the form to open the folder.  The window.open() method works well on XP workstations, but we found with the added security of Vista that window.open() does not work well with network shares.

    Place the following code in the onload event of your form, replacing new_folderfield with the name of your field:

    fieldOnDblClick = function()
        {
    var networkSharePath = crmForm.all.new_folderfield.DataValue;
    if (networkSharePath != null)
    {
    var oShell = new ActiveXObject("Shell.Application");
        oShell.Open(crmfieldnameShare);
    }
        } 
    
    crmForm.all.new_folderfield.ondblclick = fieldOnDblClick;

    You can also add a button to the form using ISV.config and setting the javascript of that button to fieldOnDblClick().

    Futher, because the code uses an ActiveX control, you have to edit the settings in IE for it to work correctly.

    1. In Internet Options, make sure the crm server is in Trustes Sites
    2. In Custom Level, confirm Initialize and script ActiveX controls not marked as safe is set to Enable
    Tuesday, April 28, 2009 2:41 PM

All replies

  • Hi,

    I need the following functionality:

    the user will register the path to a network folder (ex: \\ server01\example) then click to save it if this field should open this folder.

    someone help me?

    Thank

    Luiz Henroqie

    Hi,

    use next code:

    window.open(<network folder address>);

    Истина открывается подготовленному уму. Мой блог - http://a33ik.blogspot.com
    Tuesday, April 28, 2009 1:35 PM
    Moderator
  • We have accomplished this in 2 ways:  the first is allowing the user to doubleclick on the field to open the folder and the second is to add a button to the form to open the folder.  The window.open() method works well on XP workstations, but we found with the added security of Vista that window.open() does not work well with network shares.

    Place the following code in the onload event of your form, replacing new_folderfield with the name of your field:

    fieldOnDblClick = function()
        {
    var networkSharePath = crmForm.all.new_folderfield.DataValue;
    if (networkSharePath != null)
    {
    var oShell = new ActiveXObject("Shell.Application");
        oShell.Open(crmfieldnameShare);
    }
        } 
    
    crmForm.all.new_folderfield.ondblclick = fieldOnDblClick;

    You can also add a button to the form using ISV.config and setting the javascript of that button to fieldOnDblClick().

    Futher, because the code uses an ActiveX control, you have to edit the settings in IE for it to work correctly.

    1. In Internet Options, make sure the crm server is in Trustes Sites
    2. In Custom Level, confirm Initialize and script ActiveX controls not marked as safe is set to Enable
    Tuesday, April 28, 2009 2:41 PM
  • I blogged about creating a network path control. you might find it helpful.
    http://mscrm4ever.blogspot.com/2009/03/creating-network-path-text-control.html


    http://mscrm4ever.blogspot.com/
    Tuesday, April 28, 2009 4:32 PM
  • Yes this is good, but i cannot save the path.
    That means the explorer opens and I can navigate throught the folders, but when I have found the right folder I cannot save it to store it in the crm entity.
    Tuesday, July 21, 2009 7:37 AM
  • If you  wish to save the path to a specific file you need to use the commonDialog activeX control.

    The following blog post shows how to add a floating button to a text field. You can integrate this example with the following script. The script creates the activex control and saves the path to the text field.

    function SaveFile()
    {
         var dialog = new ActiveXObject(“MSComDlg.CommonDialog”);
         dialog.Filter = “All Files (*.*)";
         dialog.MaxFileSize = 1024;
        
         dialog.ShowOpen();
         crmForm.all.<name of field>.DataValue = dialog.FileName;
    }

    The floating button needs to implement the SaveFile function.

     


    Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/
    Tuesday, July 21, 2009 11:39 AM