Difference between revisions of "Attachments"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
==About Attachments==
==About Attachments==
{{permission|The [[Access Profile#Administrative Permissions|Administrative Permissions]] specified in the user's Access Profile determine whether a user can create Attachments, and whether they can view, update, or delete Attachments created by other team members.}}
''Attachements'' are files that are uploaded and "attached" to a Case or to a record in some other platform [[Object]].
 
;Considerations:
:* All files are added to the Attachments object, except for the special file field that comes predefined as a part of the cases object. (A file uploaded to that field is stored as part of the record.)
 
:* When viewing Case details, a button button appears that lets you upload a file to that field.
::* As with any other file field, the field changes to show the file, when a file has already been uploaded.
::* In essence, that field defines a "primary" file that can be labeled and attached to a case.
::* However, unlike other file fields, anything uploaded to the default file field in the Cases object ''also'' appears in the list of Attachments that appears in the sidebar.<br>(Files uploaded to other file fields do not appear there.)
::* So even if multiple files are added (using emails, for example), there is only ever one "primary" file associated with the case, and that file is displayed in the details area of the record.
 
:* A file added in the sidebar is a private attachment that is never visible to an external user. It is added directly to the Attachments object.
:* A file added in a Private Note or Email has a slightly different button:
::* A file added using that button also goes directly to the Attachments object.
::* If added in a Private Note, it is a private attachment that is never visible to an external user. It is only visible if it is added to an email, It is then a public attachment that does display in the service-portal file list that is visible to an external user.


==Working with Attachments==
==Working with Attachments==
Line 6: Line 21:
===Adding an Attachment===
===Adding an Attachment===
To add an attachment to a record:
To add an attachment to a record:
#...
#When viewing or creating a {{CaseRecord}}, under '''Attachment''', click '''[Select a File]'''.
#In the Add Attachment page, enter a Title for the attachment.
#When adding [[Private Notes and Email Messages]], click '''[Attach File]'''.
#Enter any text you want to include as a Description.
#When viewing a record, under '''Files''' in the sidebar, click '''Add File'''.
#Select No if you do not want the attachment to be Visible to Everyone.
#Fill in the Attachment Settings
#Under Select Attachment, enter the name of the document or click the Browse button to find and select the document you want to attach to this record.
# Click '''[Save]'''
#Click the Save button. The attachment title, owner (you), and the current date appear under Notes and Attachments in that record.


===Viewing Attachments===
===Viewing Attachments===
When viewing a {{CaseRecord}}, attachments are listed under '''Files''' in the sidebar.
When viewing a {{CaseRecord}}, attachments are listed under '''Files''' in the sidebar.
Clicking an attachment lets you download it or view it immediately, depending on your Service Provider's [[networking.properties]] configuration. (In the cloud, attachments are viewed immediately.)
===Attaching a file to a case===
To attach a file to a case record using API:
:{|
<pre>
import java.io.File;
import javax.ws.rs.core.MediaType;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
public class AttachmentUpload {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("HelloWorld");
try
        {
            File f = new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg");
           
            HttpClient client = new HttpClient();
            //Add a record to a custom object called "Attachment"
            PostMethod postMethod = new
                PostMethod("http://localhost/networking/rest/record/attachments");
           
            //Set the session for this request.
            postMethod.setRequestHeader("Cookie", "JSESSIONID=22588C70A4D95CEA5FC75C2BBDCDA564");
            //The first attribute of the FilePart constructor refers to the file field name 
                    //ie.file_field
            FilePart filePart = new FilePart("file_field", f);
           
            //Set the content type of the filePart
            filePart.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            //Create the xml part of the request
            // __xml_data__ is required for the name attribute
            // If the content type is json, use __json_data__
            StringPart sp = new StringPart("__xml_data__",
              "<platform><record><title>Some text field</title>"
            + "<file_field>Desert.jpg</file_field>"+
              "<related_to type=\"0d35c4c4af094277bbf0321478f5207a\">1200255925</related_to></record></platform>");
           
            //Set the Content-type of the xml part
            sp.setContentType(MediaType.APPLICATION_XML);
           
            final Part[] parts = { sp, filePart };
            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
           
            postMethod.addRequestHeader("Accept", "application/xml");
            //System.out.println("Execute Method:");
            int executeMethod = client.executeMethod(postMethod);
            System.out.println("Execute Method:"+executeMethod);
           
            byte[] responseBody = postMethod.getResponseBody();
            System.out.println(new String(responseBody));
           
           
           
            System.out.println("Execute Method:"+executeMethod);
        }
        catch(Exception e)
        {
            System.out.println("Exception"+e.getMessage());
        }
}
}
</pre>
|}

Latest revision as of 10:34, 27 October 2016

About Attachments

Attachements are files that are uploaded and "attached" to a Case or to a record in some other platform Object.

Considerations
  • All files are added to the Attachments object, except for the special file field that comes predefined as a part of the cases object. (A file uploaded to that field is stored as part of the record.)
  • When viewing Case details, a button button appears that lets you upload a file to that field.
  • As with any other file field, the field changes to show the file, when a file has already been uploaded.
  • In essence, that field defines a "primary" file that can be labeled and attached to a case.
  • However, unlike other file fields, anything uploaded to the default file field in the Cases object also appears in the list of Attachments that appears in the sidebar.
    (Files uploaded to other file fields do not appear there.)
  • So even if multiple files are added (using emails, for example), there is only ever one "primary" file associated with the case, and that file is displayed in the details area of the record.
  • A file added in the sidebar is a private attachment that is never visible to an external user. It is added directly to the Attachments object.
  • A file added in a Private Note or Email has a slightly different button:
  • A file added using that button also goes directly to the Attachments object.
  • If added in a Private Note, it is a private attachment that is never visible to an external user. It is only visible if it is added to an email, It is then a public attachment that does display in the service-portal file list that is visible to an external user.

Working with Attachments

Adding an Attachment

To add an attachment to a record:

  1. When viewing or creating a a Case record or some other record, under Attachment, click [Select a File].
  2. When adding Private Notes and Email Messages, click [Attach File].
  3. When viewing a record, under Files in the sidebar, click Add File.
  4. Fill in the Attachment Settings
  5. Click [Save]

Viewing Attachments

When viewing a a Case record or some other record, attachments are listed under Files in the sidebar.

Clicking an attachment lets you download it or view it immediately, depending on your Service Provider's networking.properties configuration. (In the cloud, attachments are viewed immediately.)

Attaching a file to a case

To attach a file to a case record using API:

import java.io.File;

import javax.ws.rs.core.MediaType;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;

public class AttachmentUpload {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("HelloWorld");
		 try
	        {
	            File f = new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg");
	            
	            HttpClient client = new HttpClient();

	            //Add a record to a custom object called "Attachment"
	            PostMethod postMethod = new 
	                PostMethod("http://localhost/networking/rest/record/attachments");
	            
	            //Set the session for this request.
	            postMethod.setRequestHeader("Cookie", "JSESSIONID=22588C70A4D95CEA5FC75C2BBDCDA564");

	            //The first attribute of the FilePart constructor refers to the file field name 
                    //ie.file_field 
	            FilePart filePart = new FilePart("file_field", f);
	            
	            //Set the content type of the filePart
	            filePart.setContentType(MediaType.APPLICATION_OCTET_STREAM);

	            //Create the xml part of the request
	            // __xml_data__ is required for the name attribute 
	            // If the content type is json, use __json_data__
	            StringPart sp = new StringPart("__xml_data__",
	              "<platform><record><title>Some text field</title>"
	            + "<file_field>Desert.jpg</file_field>"+
	            		  "<related_to type=\"0d35c4c4af094277bbf0321478f5207a\">1200255925</related_to></record></platform>");
	            
	            //Set the Content-type of the xml part
	            sp.setContentType(MediaType.APPLICATION_XML);
	            
	            final Part[] parts = { sp, filePart };

	            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
	            
	            postMethod.addRequestHeader("Accept", "application/xml");
	            //System.out.println("Execute Method:");
	            int executeMethod = client.executeMethod(postMethod);
	            System.out.println("Execute Method:"+executeMethod);
	            
	            byte[] responseBody = postMethod.getResponseBody();

	            System.out.println(new String(responseBody));
	            
	            
	            
	            System.out.println("Execute Method:"+executeMethod);
	        }
	        catch(Exception e)
	        {
	            System.out.println("Exception"+e.getMessage());
	        }

	}

}