Dynamic CRM 2013 Learning Notes (13) Attachments upload/upload attachments

Source: Internet
Author: User

Uploading attachments may be a common requirement in CRM, this article will introduce how to implement the attachment upload, display and download in CRM. The following steps are included:

    • Web page for attachment upload
    • Attachment display and downloaded attachment entities
    • Invoke JS file to upload Web page
    • Upload button for R on entity

    • first Look at the effect:

First click on the Upload button above, then will pop up an upload attachment interface, select the file to upload, fill in the filename, click Upload, successful will be in the following file grid to display the uploaded files, double-click the following file will open the file details:

You can then also download the file.

    • Here's a look at the implementation method

1. Web pages uploaded by attachments

Create a new normal Web program, plus an ASPX page for file uploads, using the uplodify in jquery:

This is the JS code to implement the upload

  1:  function ()
  2:         {
  3:             uploadfiles ();
  4:         });
  
  6:         function uploadfiles ()
  7:         {
  8:             $ ("#uploadify"). Uploadify ({
  9: '                 swf ': ' scripts/upload/uploadify.swf ',
Ten: '                 uploader ': ' Uploader.ashx ',
One: '                 queueid ': ' Filequeue ',
:                 ' auto ': false,
:                 ' multi ': true,
:                 ' onuploaderror ': function (file, ErrorCode, ErrorMsg, errorstring)
:                 {
:                     ' the file ' + File.name + ' could not being uploaded: ' + errorstring ';
:                 },
:                 ' onuploadsuccess ': function (file, data, response)
:                 {
:                     ' <li><a href= ' + data + ' "> ' + file.name + ' </a></li> '). AppendTo ($ (' ul '));
:                 }
:             });
:         }
:         function Upload ()
:         {
:             ' #uploadify '). Uploadify (' upload ', ' * ');
:         }

This is what is displayed on the page:

  1:   class= "gbtext" >
  2:             <tr>
  3:                 <td>
  4:                    <input type= "file" name= "uploadify" id= "uploadify"/>
  5:                 </td>
  6:                 <td>
  7:                     <input type= "button" value= "Upload Filesclass="Uploadify-button" style= "height:25px; width:112px;"  Onclick= "javascript: $ (' #uploadify '). Uploadify (' upload ', ' * ')"/>
  8:                     <input id= "Yesclass="button"onclick="upfiles ();" onmouseout= "this.classname= ' button '" onmouseover= "this.classname= ' button-hover '" style= " width:50px"type="button"value="Confirm"/>
  9:                 </td>
Ten:             </tr>
One:             <tr>
:                 <td colspan= "2" >
:                     <ul id= "ul" ></ul>
:                 </td>
:             </tr>
:         </table>
:     <div id= "filequeue" >

Finally put it under the ISV:

2. Attachment Entities

    • Field

The fields in the red box are the lookup type, the ID of the entity that needs to implement the upload function, and the rest is the basic field

    • Interface

The Middle red box is an IFRAME, and nothing else is introduced:

    • Invoke JS file to upload Web page
  var uploadcfg = {
  2:     fileFloder:Xrm.Page.data.entity.getEntityName (),
  3:     entityReferenceName:Xrm.Page.data.entity.getEntityName () + "ID",
  4:     entityName:Xrm.Page.data.entity.getEntityName (). toLowerCase ()
  5:};
  
  function UploadFile () {
  8:     var openURL = "/isv/filesupload/fileupload.aspx?" filefolder="+ Uploadcfg.filefloder +"&entityname="+ uploadcfg.entityname
  9:         + "&entityreferencename=" + uploadcfg.entityreferencename + "&entityid=" + Xrm.Page.data.entity.getId ()
Ten:         + "&userid=" + Xrm.Page.context.getUserId ();
One:     windowshowmodaldialog (OpenURL, "_blank", "dialogwidth=500px;dialogheight=300px; Help:no;status:no");    //Open modal form
12:}

    • Upload button

Add a button and specify the function name UploadFile

/_imgs/ribbon/addconnection_16.png

UploadFile

$webresource: New_upload_file.js

Dynamic CRM 2013 Learning Notes Series Rollup

Dynamic CRM 2013 Learning Notes (13) Attachments upload/upload attachments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.